2017-02-22 76 views
1

當我嘗試將$ uibModal注入到新狀態時出現錯誤。 在其他國家它正常工作。什麼可能是錯誤的原因?

錯誤日誌

Error: [$injector:unpr] http://errors.angularjs.org/1.5.7/$injector/unpr?p0=49d19463-4701-4df9-ba96-5053f03a665bProvider%20%3C-%2049d19463-4701-4df9-ba96-5053f03a665b 
at angular.min.js:6 
at angular.min.js:43 
at Object.d [as get] (angular.min.js:40) 
at angular.min.js:43 
at Object.d [as get] (angular.min.js:40) 
at ui-bootstrap-tpls.js:3656 
at Object.r [as forEach] (angular.min.js:8) 
at Object.resolve (ui-bootstrap-tpls.js:3652) 
at Object.$modal.open (ui-bootstrap-tpls.js:4256) 
at b.$scope.showNotification (NotificationsController.js:19) 

我控制器

angular.module('EProc.Notifications') 
.controller('notificationsCtrl', ['$scope', '$http', '$uibModal', 
    function($scope, $http, $uibModal){ 

     $http.get('/api/notification/lastmsg').then(function(result) { 
      console.log('last 10 notifications--------------------'); 
      console.log(result); 
      $scope.lastNotifications = result.data.content; 
      $scope.newMessages = result.data.newMessages; 
     }); 

     $http.get('/api/notification/messages').then(function(result) { 
      console.log('all notifications--------------------'); 
      console.log(result); 
      $scope.allNotifications = result.data.content; 
     }); 

     $scope.showNotification = function(id) { 
      $uibModal.open({ 
       animation: true, 
       size: 'md', 
       templateUrl: 'client/components/notifications/tmpl/notificationModal.html', 
       controller: 'notificationModalCtrl', 
       resolve: { 
        id: id 
       } 
      }); 
     } 
    } 
]) 
.controller('notificationModalCtrl', ['$scope', 'id', '$uibModalInstance', 
    function($scope, id, $uibModalInstance){ 
     $http.get('/api/notification/message/' + id).then(function(result) { 
      $scope.notification = result.data; 
     }) 
}]); 

mainApp.js

var eProcApp = angular.module('EProc', 
[ 
    'ui.router', 
    'ui.bootstrap', 
    'smart-table', 
    'ngTagsInput', 
    'EProc.Common', 
    'EProc.Profile', 
    'EProc.Purchasers', 
    'EProc.Supply', 
    'EProc.Tenders', 
    'EProc.Notifications' 
]); 

eProcApp.config(['$stateProvider', '$httpProvider', '$urlRouterProvider', 
function ($stateProvider, $httpProvider, $urlRouterProvider) { 

    $stateProvider 

     .state('myprofile', { 
      url: '/myprofile', 
      templateUrl: 'client/components/profile/tmpl/profileShortDetails.html', 
      controller: 'profileDetailsCtrl' 
     }) 

     .state('main', { 
      url: '/main', 
      views: { 
       '': { 
        templateUrl: 'client/components/purchase/tmpl/annualPlans.html' 
       }, 
       '[email protected]': { 
        templateUrl: 'client/components/purchase/tmpl/procurementPlan.html', 
        controller: 'annualProcPlanCtrl' 
       } 
      } 
     }) 

     .state('purchasers', { 
      url: '/purchasers/:purchaserId', 
      views: { 
       '': { 
        templateUrl: 'client/components/purchase/tmpl/purchasers.html', 
        controller: 'purchasersListCtrl' 
       } 
      } 
     }) 

     .state('purchasers.procplan', { 
      url: "/procplan", 
      templateUrl: 'client/components/purchase/tmpl/procurementPlan.html', 
      controller: 'procurementPlanCtrl' 
     }) 

     .state('purchasers.children', { 
      url: "/children", 
      templateUrl: 'client/components/purchase/tmpl/childrenPartiesList.html', 
      controller: 'childrenPurchasersCtrl' 
     }) 

     .state('procplan', { 
      url: '/procplan/:purchaserId', 
      views: { 
       '': { 
        templateUrl: 'client/components/purchase/tmpl/procurementPlan.html', 
        controller: 'procurementPlanCtrl' 
       } 
      } 
     }) 

     .state('procitem', { 
      url: '/procitem/:itemId', 
      templateUrl: 'client/components/purchase/tmpl/procurementItem.html', 
      controller: 'procurementItemCtrl' 
     }) 

     .state('search', { 
      url: '/procitem/search/:page?searchText', 
      params: {'filter': {}}, 
      views: { 
       '': { 
        templateUrl: 'client/components/purchase/tmpl/searchProcItems.html', 
        controller: 'searchProcItemsCtrl' 
       }, 
       '[email protected]': { 
        templateUrl: 'client/components/purchase/tmpl/search/resultsSectionsView.html', 
        controller: 'procItemSearchResultsCtrl' 
       } 
      } 
     }) 

     .state('favgroups', { 
      url: '/favgroups', 
      templateUrl: 'client/components/supply/tmpl/favoriteGroups.html', 
      controller: 'favoriteGroupsCtrl' 
     }) 

     .state('favorites', { 
      url: '/favorites/:gswId', 
      templateUrl: 'client/components/supply/tmpl/favoritesList.html', 
      controller: 'favoritesListCtrl' 
     }) 

     .state('proposals', { 
      url: '/proposals', 
      templateUrl: 'client/components/supply/tmpl/commProposalsList.html', 
      controller: 'commProposalListCtrl' 
     }) 

     .state('proposal', { 
      url: '/proposal/:procItemId', 
      templateUrl: 'client/components/supply/tmpl/commProposal.html', 
      controller: 'commProposalCtrl' 
     }) 

     .state('tenders', { 
      url: '/tenders/', 
      templateUrl: 'client/components/tenders/tmpl/tendersList.html', 
      controller: 'tendersListCtrl' 
     }) 

     .state('announcement', { 
      url: '/announcement/:announcementId', 
      templateUrl: 'client/components/tenders/tmpl/singleAnnouncementView.html', 
      controller: 'viewAnnouncementCtrl' 
     }) 

     .state('watchlist', { 
      url: '/watchlist/', 
      templateUrl: 'client/components/supply/tmpl/keywordMatchWatchList.html', 
      controller: 'kwMatchWatchListCtrl' 
     }) 

     .state('notifications', { 
      url: '/notifications', 
      templateUrl: 'client/components/notifications/tmpl/notifications.html', 
      controller: 'notificationsCtrl' 
     }); 

    $httpProvider.interceptors.push('loginInterceptor'); 
}]); 

回答

2

resolve屬性值必須是功能,即

resolve: { 
    id: function() { return id } 
} 
+0

非常感謝,它的工作:) – kg2152