2017-01-03 33 views
0

我從控制器傳遞一些數據到模態控制器。ng:areq:解析數據Angular UI Modal

在我的控制器:

 vm.timetableModal = modals.open.timetable(vm.store.formatted_working_hours || null); 
     vm.timetableModal.result.then(function (res) { 
      vm.store.formatted_working_hours = res.formatted_working_hours; 
     }) 

在模態廠:

function timetable(current_working_hours) { 
      return $uibModal.open({ 
       templateUrl: 'templates/modals/timetable_modal.html', 
       controller: 'timeTableCtrl', 
       controllerAs: 'tm', 
       resolve: { 
        current_working_hours: current_working_hours 
       } 
      }); 
     } 

current_working_hours不爲空,將出現問題。

實際的錯誤是:

"Error: [ng:areq] http://errors.angularjs.org/1.5.8/ng/areq?p0=fn&p1=not%20a%20function%2C%20got%20Object

回答

0

的問題是,我不得不這樣做是這樣的:

resolve: { 
      current_working_hours: function() { 
       return current_working_hours; 
     } 

的這個代替:

resolve: { 
      current_working_hours: current_working_hours 
     }