我一直得到JSONFilterProvider< - JSONFilter Unpr Angular错误,我不知道为什么

时间:2015-08-06 00:53:12

标签: javascript angularjs internet-explorer-8

这是我正在做的事情的代码:

<!-- underscore -->
    <script src="js/underscore.js/underscore.js" type="text/javascript"></script>
    <!-- Scripts -->
    <script src="js/bootstrap/bootstrap.min.js"></script>
    <script src="js/jquery/jquery.mixitup.min.js"></script>
    <!-- Angular -->
    <script src="js/angular/app.js" type="text/javascript"></script>
    <script src="js/angular/controllers/controllers.js" type="text/javascript"></script>
    <script src="js/angular/directives/directives.js" type="text/javascript"></script>
    <script src="js/angular/services/data-service.js" type="text/javascript"></script>

上面的代码位于底部。

这是我在Google中遇到的错误

错误:[$ injector:unpr]未知提供者:JSONFilterProvider&lt; - JSONFilter     http://errors.angularjs.org/1.4.2/ $注射器/ unpr?P0 = JSONFilterProvider%20%3 C-%20JSONFilter     在REGEX_STRING_REGEXP(http://localhost/website/js/angular/angular.js:68:12)     在http://localhost/website/js/angular/angular.js:4264:19     at Object.getService [as get](http://localhost/website/js/angular/angular.js:4411:39)     在http://localhost/website/js/angular/angular.js:4269:45     at Object.getService [as get](http://localhost/website/js/angular/angular.js:4411:39)     at $ get(http://localhost/website/js/angular/angular.js:18091:24)     at isStateless(http://localhost/website/js/angular/angular.js:12956:12)     在findConstantAndWatchExpressions(http://localhost/website/js/angular/angular.js:13013:33)     在http://localhost/website/js/angular/angular.js:12967:7     在forEach(http://localhost/website/js/angular/angular.js:336:20

我正在使用angular-ui-router.js vice ng-Route。

问题是,代码中的NOWHERE我引用了JSONFilter ......

错误出现在此处的angular.js:12321

// The reason behind this is that console.log has type "object" in IE8...
  try {
    hasApply = !!logFn.apply;
  } catch (e) {}

  if (hasApply) {
    return function() {
      var args = [];
      forEach(arguments, function(arg) {
        args.push(formatError(arg));
      });
      return logFn.apply(console, args);
    };
  }

我没有使用IE8,也没有使用互联网爆炸或现在,立即让病毒感染的边缘。我把它丢弃在WINDOWS 10上。

重点关注。任何线索来自何处或我如何得到它?

BTW这是我的app.js文件:

/* global angular */

// Code goes here
var myApp;
myApp = angular.module("myApp", [
    "ui.router"

]);


myApp.config(function ($sceDelegateProvider) {

    $sceDelegateProvider.resourceUrlWhitelist(['self', '**']);


});
myApp.config(function ($stateProvider, $urlRouterProvider) {

    // For any unmatched url, send to /route1
    $urlRouterProvider.otherwise("home");

    $stateProvider
            .state('home', {
                url: "/home",
                views: {
                    "mainHeader": {
                      templateUrl: "templates/mainHeader.html"  

                    },
                    "mainNav": {
                      templateUrl: "templates/mainNav.html"  

                    },
                    "mainContent": {
                        templateUrl: "templates/home.html"

                    },
                    "mainFooter": {
                        templateUrl: "templates/mainFooter.html"

                    },
                    "homeDetails": {
                        templateUrl: 'templates/home-details.html'

                    }

                }

            })
            .state('about', {
                url: "about",
                views: {
                    "mainAbout": {
                        templateUrl: "templates/about.html"
                    },
                    "aboutDetails": {
                        templateUrl: 'templates/about-details.html'

                    }
                }

            });
});

console.log("Host name is: " + document.location.hostname);

if (document.location.hostname === "localhost") {
    myApp.constant('URL', '/website/js/json/');
} else if (document.location.hostname === "website.net" || "www.website.net") {
    myApp.constant('URL', '/js/json/');
} else {
    myApp.constant('URL', '/website/js/json/');
}


//Registering the company for the key achievements
//This defines and initializes a value service called company and assigns it an 
//object with some default values.

myApp.constant("nbrCompanies", {
    nbr: 0
});
myApp.constant("nbrSites", {
    nbr: 0
});
myApp.constant("nbrSkills", {
    nbr: 0
});

感谢您的帮助......

更新:这是包含ui-views

的内容

    <div class="container" ng-controller="homeController as ctrlHome">
        <!-- Nav UI View -->
        <nav id="mainbar" class="hidden-xs" ui-view="mainNav"></nav>
        <!-- Nav UI View -->
        <div id="wrap">
            <!-- injected header content -->
            <div id="header" ui-view="mainHeader"></div>
            <!-- injected main content -->
            <div id="bodyStuff" ui-view="mainContent"></div>
            <!-- End of Injected Content-->
            <!-- Detail View -->
            <div class="details" ui-view="homeDetails"></div>
            <!-- End Detail View -->  
        </div> <!-- wrap -->
        <footer id="footer" ui-view="mainFooter"></footer>
    </div> <!-- container -->
    <!-- underscore -->
    <script src="js/underscore.js/underscore.js" type="text/javascript"></script>
    <!-- Scripts -->
    <script src="js/bootstrap/bootstrap.min.js"></script>

    <!-- Angular -->
    <script src="js/angular/app.js" type="text/javascript"></script>
    <script src="js/angular/controllers/controllers.js" type="text/javascript"></script>
    <script src="js/angular/directives/directives.js" type="text/javascript"></script>
    <script src="js/angular/services/data-service.js" type="text/javascript"></script>

</body>

1 个答案:

答案 0 :(得分:0)

我发现了问题:

在我的home.html页面的调用中,我有以下代码:

<div class="feature-widget">
            <article class="home-features-item hover">
                <div class="item-icon">
                    <i class="fa fa-html5"></i>
                </div>
                <div class="item-content">
                    <h3>Lorem ipsum mollit sunt</h3>
                    <!-- This is where the culprit was... SHOW is what was NEEDED -->
                    **<a ui-sref="detail({id: show.id})">{{show.name}}</a>**
                    <!-- This is what I had:... the word SHOWS was wrong
                    **<a ui-sref="detail({id: show.id})">{{shows.name}}</a>**
                    -->
                    <pre hidden="hidden">{{show|json}}</pre>
                    <p>Lorem ipsum Labore adipisicing nisi magna do nisi pariatur aliquip eu sed voluptate consequat sunt aute aliqua exercitation minim cupidatat.</p>
                    <p>Lorem ipsum Ut dolor et anim occaecat ex aliquip esse labore fugiat in do magna dolore pariatur eiusmod irure officia.</p>
                </div>
            </article> <!-- home-features-item -->
        </div> <!-- feature-widget -->

这里是我搞砸的控制器和服务:

控制器:

/* global myApp, ctrlRes */

'use strict';

myApp.controller('homeController',
    ['$scope','$state','homeDataService',
        function ($scope, $state, homeDataService) {
            var ctrlHome = this;

            ctrlHome.content = [];

            ctrlHome.fetchHome = function () {
                //General Data
                homeDataService.getHomeData().then(function (result) {
                    ctrlHome.content = result.data;
                    console.log("General: ", result.data);
                });
            };
            ctrlHome.fetchHome();

            //Redirects to a page sent into this function
            $scope.redirectToPage = function (pageToGoTo) {
                //if pageToGoTo = home, then route to /home!
                $state.go(pageToGoTo);
            };

            //Now we route with lists
            $scope.home = homeDataService.list();

}]);
//This is the details for HOME
myApp.controller('homeDetailController', 
    ['$scope','$stateParams', 'homeDataService', 
        function($scope, $stateParams, homeDataService) {

            var ctrlHmDets = this;
            ctrlHmDets.content = [];

            ctrlHmDets.content = homeDataService.find($stateParams.id);
            $scope.selectedShow = homeDataService.find($stateParams.id);


 }]);

SERVICE:

/* global myApp, _ */
var shows = [];

myApp.factory('homeDataService', function ($http, URL) {
    var getHomeData = function () {
        return $http.get(URL + 'general-junk.json')
                .success(function (data) {
                    console.log("SUCCESS!");
                    console.log("The General Junk Home: " + data.basedata.companyinfo);
                    return data.basedata.companyinfo;
                })
                .error(function (e) {
                    console.log("He\'s dead Jim!", e);
                    return e;
                });

    };

    //Details for the Home Page
    shows = [{
        id: 1,
        page: 'Home',
        name: 'Home Details',
        description: 'This is the detail content'
    }];
    return {
        getHomeData: getHomeData,
        list: function () {

            return shows;

        }, //This is for DETAILs if we should have them
        find: function (id) {
            return _.find(shows, function (show) {
                return show.id === id;
            });
        }
    };



});

谢谢,杰夫的灵感所以DEBUG!

相关问题