Angular-ui-router依赖性错误

时间:2015-07-17 06:57:38

标签: angularjs angular-ui-router

好的,为了记录,我有一个工作项目,我不得不改变它的咕噜声工作流程,现在angular-ui-router给我一个不可理解的错误。

这是我在关注angularjs链接时得到的结果:

Failed to instantiate module app due to:
Failed to instantiate module ui.router due to:
Failed to instantiate module ui.router.state due to:

Uncaught Error: [$injector:modulerr]
http://errors.angularjs.org/1.3.15/$injector/modulerr?p0=app&p1=Error%3A%20…Flocalhost%3A8080%2Fapp%2Fcomponents%2Fangular%2Fangular.min.js%3A38%3A135)(anonymous
function) @ angular.min.js:6(anonymous function) @ angular.min.js:35r
@ angular.min.js:7g @ angular.min.js:34ab @ angular.min.js:38d @
angular.min.js:17uc @ angular.min.js:18Jd @
angular.min.js:17(anonymous function) @
angular.min.js:250n.Callbacks.j @
jquery.min.js:2n.Callbacks.k.fireWith @ jquery.min.js:2n.extend.ready
@ jquery.min.js:2I @ jquery.min.js:2
我很失落,我试着降级到棱镜1.3.15,没带任何东西。包含脚本的顺序如下:

components/html5-boilerplate/dist/js/vendor/modernizr-2.8.3.min.js
components/jquery/dist/jquery.min.js
components/highcharts/highcharts.js
components/bootstrap/dist/js/bootstrap.min.js
components/socket.io-client/socket.io.js
components/bootstrap-switch/dist/js/bootstrap-switch.min.js
components/lodash/lodash.min.js
components/gsap/src/minified/TweenMax.min.js
components/gsap/src/minified/easing/EasePack.min.js
components/PreloadJS/lib/preloadjs-0.6.1.min.js
components/humanize-duration/humanize-duration.js
components/momentjs/min/moment-with-locales.min.js

components/angular/angular.min.js

components/angular-ui-router/release/angular-ui-router.min.js
components/angular-cookies/angular-cookies.min.js
components/ng-tags-input.min/ng-tags-input.min.js
components/angular-sanitize/angular-sanitize.min.js
components/angular-animate/angular-animate.js
components/restangular/dist/restangular.min.js
components/angular-fullscreen/src/angular-fullscreen.js
components/angular-bootstrap/ui-bootstrap.min.js
components/angular-bootstrap/ui-bootstrap-tpls.min.js
components/angular-bootstrap-switch/dist/angular-bootstrap-switch.min.js
components/highcharts-ng/dist/highcharts-ng.min.js
components/ng-droplet/dist/ng-droplet.min.js
components/angular-timer/dist/angular-timer.min.js

src/constants-app.js src/app.js

src/admin/admin-controller.js
src/admin/events/events-controller.js
src/admin/moderation/bans-controller.js
src/admin/moderation/message-modal/message-modal-controller.js
src/admin/moderation/moderation-controller.js
src/admin/partners/partners-controller.js
src/admin/reports/reports-controller.js
src/admin/user/invites/invites-controller.js
src/admin/user/linked/linked-accounts-controller.js
src/admin/user/password/password-controller.js
src/admin/user/user-controller.js src/admin/votes/votes-controller.js
src/adminboard/adminboard-controller.js src/root-controller.js
src/shared/alerts/alerts-controller.js
src/shared/alerts/alerts-directive.js
src/shared/clock/clock-directive.js src/shared/crap.js
src/shared/filters/url-filter.js src/shared/main-controller.js
src/shared/modals/confirm-modal-controller.js
src/shared/purchase-credit-modal/purchase-credit-controller.js
src/shared/purchase-modal/purchase-modal-controller.js
src/shared/services/event-service.js
src/shared/services/message-service.js
src/shared/services/modal-helper-service.js
src/shared/services/queue-service.js
src/shared/services/socket-service.js
src/shared/services/user-service.js
src/shared/services/vote-service.js
src/shared/spinner/spinner-directive.js
src/shared/spinner/spinner-service.js
src/wall/bottomOverlay/bottomOverlay-controller.js
src/wall/bottomOverlay/bottomOverlay-directive.js
src/wall/counters/counters-controller.js
src/wall/counters/counters-directive.js
src/wall/messages/messages-directive.js
src/wall/messages/messages-settings-controller.js
src/wall/slideshow/slideshow-directive.js
src/wall/slideshow/slideshow-settings-controller.js
src/wall/topOverlay/topOverlay-controller.js
src/wall/topOverlay/topOverlay-directive.js
src/wall/vote/vote-directive.js src/wall/wall-controller.js

我用有趣的块分隔了潦草。我包括角度,ui路由器和其他部分。

这是我的app.js文件内容:

// Declare modules.
angular.module('app')

    //ui.routes
    .config(['$stateProvider','$urlRouterProvider','$locationProvider',function($stateProvider, $urlRouterProvider, $locationProvider) {
        "use strict";

        $locationProvider.html5Mode(true);  //Remove # in angular urls.

        $stateProvider
            .state('root',{ //here we resolve all the application wide stuff. Like user.
                url : '',
                controller : 'rootController',
                template : '<ui-view id="rootView"></ui-view>',
                resolve : {
                    user : ['Restangular',function(Restangular){
                        return Restangular.all('users').customGET('self');
                    }]
                }
            })

            //MODALS

            //BUY CREDIT
            .state('purchaseCredit',{
                url : '/purchaseCredit'
            })

            .state('slideShowSettings',{
                url : '/slideShowSettings'
            })

            .state('messagesSettings',{
                url : '/messageSettings'
            })

            .state('root.admin',{
                url : '/admin',
                templateUrl : 'src/admin/admin.html',
                controller : 'adminController'
            })

            //show user account infos, and actions.
            .state('root.admin.user',{
                url : '/user',
                templateUrl : 'src/admin/user/user.html',
                controller: 'userController'
            })

            //edit user password
            .state('root.admin.user.password',{
                url : '/password',
                templateUrl : 'src/admin/user/password/password.html',
                controller : 'passwordController'
            })

            //show invites list.
            .state('root.admin.user.invites',{
                url : '/invites',
                templateUrl : 'src/admin/user/invites/invites.html',
                controller : 'invitesController',
                resolve : {
                    invites: ['Restangular', 'user', function (Restangular, user) {
                        return Restangular.all('invites').getList({parentId : user._id}); //todo limit to my invites.
                    }]
                }
            })

            //show one invite.
            /* .state('root.admin.user.invites.detail',{
             url : '/:id',
             templateUrl : 'src/admin/user/invites/invite.html',
             controller : 'inviteController',
             resolve : {
             invite : ['$stateParams', function($stateParams){
             if(!$stateParams.id){ return {}; }
             return Restangular.one('invites',$stateParams.id).get();
             }]
             }
             })*/

            /* LINKED ACCOUNTS */

            //list of linked accounts ( people who accepted invite )
            .state('root.admin.user.linkedAccounts',{
                url : '/linkedAccounts',
                templateUrl : 'src/admin/user/linked/linkedAccounts.html',
                controller : 'linkedAccountsController',
                resolve : {
                    linkedAccounts : ['Restangular', 'user', function (Restangular, user) {
                        var query = { parent : user._id/*, sort : '_id', limit : 20, skip : 0*/};
                        console.warn('gonna fetch', query);
                        return Restangular.all('users').getList(query);
                    }]
                }
            })

            .state('root.admin.events',{
                url : '/events',
                templateUrl : 'src/admin/events/events.html',
                controller : 'eventsController'
            })

            .state('root.admin.moderation', {
                url: '/moderation',
                templateUrl : 'src/admin/moderation/moderation.html',
                controller: 'moderationController'
            })

            .state('root.admin.bans',{
                url : '/bans',
                templateUrl : 'src/admin/moderation/bans.html',
                controller : 'bansController'
            })

            .state('root.admin.reports',{
                url : 'admin.reports',
                templateUrl : 'src/admin/reports/reports.html',
                controller : 'reportsController'
            })

            .state('root.admin.votes',{
                url : '/votes/:id',
                templateUrl : 'src/admin/votes/votes.html',
                controller : 'votesController'
            })

            .state('root.wall',{
                url : '/wall/:eventId',
                templateUrl : 'src/wall/wall.html',
                controller: 'wallController'
            })

            .state('root.vote',{ //display vote for conference. integration in powerpoint.
                url : '/vote/:voteId',
                templateUrl : 'src/vote/vote.html',
                controller : 'voteController'
            })

            .state('root.adminboard',{
                url : '/adminboard',
                templateUrl : 'src/adminboard/adminboard.html',
                controller : 'adminBoardController'
            });

        $urlRouterProvider.otherwise('/admin/events'); //redirect. default to events page.
    }])//restangular
    .config(['RestangularProvider',function(RestangularProvider) {
        "use strict";

        RestangularProvider
            .setBaseUrl('/api/v1/')
            .setRestangularFields({
                id: "_id"
            })
            .setDefaultHeaders({'Content-Type': 'application/json'})
            .setRequestInterceptor(function(elem, operation, what) {
                if (operation === 'put' || operation === 'post') {
                    elem._id = undefined;
                    elem.__v = undefined;
                    return elem;
                }
                return elem;
            });


    }]).run(['Restangular', '$window','socketService', function(Restangular, $window, socketService ){
        'use strict';
        Restangular.extendModel('events', function(model) {
            if(typeof model !== 'object'){ //todo sometimes ( reset ) gives back a non object.
                return false;
            }

            model.isStarted = function() { //adds started method to all events objects.
                return (this.startedUntil ? ( (new Date(this.startedUntil).getTime() > Date.now())) : false);
            };

            model.hasMessages = function(){
                return model.config.phone ||((model.counts.sms + model.counts.appli + model.counts.admin) > 0);
            };

            model.hasPhone = function(){
                return (typeof model.config.phone === 'string');
            };

            model.hasFacebook = function(){
                return model.config.facebookAccounts;
            };

            model.hasTweeter = function(){
                return model.config.twitterHashtags.length;
            };

            model.hasInstagram = function(){
                return model.config.instagramHashtags.length;
            };

            return model;
        });

        Restangular.extendModel('users', function(model){ //if user has trial offer and event is started.
            model.isTrial = function(){
                _.filter(model.offers,function(offer){ //todo make this a function of user? (isTrial)
                    return (offer.type === 'trial' && (new Date(offer.until).getTime() > Date.now()) );
                });
            };
            return model;
        });
        Restangular.setErrorInterceptor(
            function(response, deferred, responseHandler) {
                if (response.status === 401) {
                    console.log("Login required... ");
                    $window.location.href = '/login';
                } else if (response.status === 404) {
                    console.log("Resource not available...");
                } else if (response.status === 500) {
                    console.log("Response received with HTTP error code: " + response.status );
                    return true;
                } else if (response.status === 403){
                    return true;
                }
                return false; // stop the promise chain
            }
        );/*.setDefaultRequestParams({ socketId : socketService.socket.id});*/
    }]).run(['$rootScope','$modal',function($rootScope, $modal){
        "use strict";
        /**
         * Listen to the `$stateChangeStart` event
         */
        $rootScope.$on('$stateChangeStart', function (event, toState, toParams) {

            //if the new state is not "terms", then ignore it
            switch(toState.name){
                case 'purchaseCredit' :
                  //  console.warn('opencredit!');

                    $modal.open({
                        templateUrl :  'src/shared/purchase-credit-modal/purchase-credit-modal.html',
                        controller : 'purchaseModalController',
                        resolve : {
                            user : function(){return toParams.user; }
                        }
                    });

                    break;

                case 'slideShowSettings' :
                    //console.error('look here toparams',toParams);
                    $modal.open({
                        templateUrl : 'src/wall/slideshow/slideshow-settings-modal.html',
                        controller : 'slideshowSettingsController',
                        size:'sm'
                    });
                    break;

                case 'messagesSettings' :
                    $modal.open({
                        templateUrl : 'src/wall/messages/messages-settings-modal.html',
                        controller : 'messagesSettingsController',
                        size:'sm'
                    });
                    break;

                default :  //its not a modal state.
                    return;
            }

            event.preventDefault(); //prevent transition to the modal's state.
        });
    }]).controller('HelloWorldController', ['$scope', function($scope) {
        "use strict";
        $scope.greeting = 'Hello World!';
    }]);

这是我的常量app.js内容:

angular.module('app', ['ngSanitize', 'ngCookies', 'ngAnimate', 'ui.router', 'highcharts-ng', 'restangular', 'FBAngular', 'ngDroplet', 'ngTagsInput', 'ui.bootstrap', 'ngDroplet', 'frapontillo.bootstrap-switch', 'timer'])

.constant('App.constants.version', '0.2.0');

什么可能导致此错误?我坚持了好几天。我试着评论出来但错误又回来了。

0 个答案:

没有答案