我的角度应用程序有一些情态动词的,我有AngularUI提供模态指令。
My Angular application has a number of modals, and I have AngularUI to provide the modal directive.
http://angular-ui.github.io/bootstrap/
到目前为止,我有几个主要的控制器,而这些都在app.js文件路径。
So far I have several main controllers, and these are all in the app.js file as routes.
$routeProvider.when '/dashboard', templateUrl: '/templates/dashboard/dashboard.html', controller: 'DashboardController'
$routeProvider.when '/dataset/:panel_id', templateUrl: '/templates/dataset/dataset.html', controller: 'DatasetController'
$routeProvider.when '/batches/:panel_id', templateUrl: '/templates/design/design.html', controller: 'PanelController'
这工作得很好。
然后,我创建了一个调用模式的函数,模态有 ConfigureModalCtrl 的实例控制器。我最初有这个在调用控制器文件的底部,和它的工作确定。
Then I created a function which calls a modal, and the modal has an instance controller of ConfigureModalCtrl. I initially had this at the bottom of the calling controller file, and it worked OK.
$scope.invokeConfigureModal = (assay_id) ->
$scope.assay_id = assay_id
$scope.primer3 = $scope.getPrimer(assay_id)
modalInstance = $modal.open(
templateUrl: '/templates/configure_modal/configure_modal.html'
controller: ConfigureModalCtrl
windowClass: 'configure-dialog'
resolve:
primer3: ->
$scope.primer3
)
modalInstance.result.then ((primer3) ->
$scope.primer3 = primer3
return
), ->
return
现在我提出的模式实例控制器到它自己的文件,但调用函数无法找到它。
Now I have moved the modal instance controller into it's own file, but the calling function cannot find it.
angular.module('assaypipelineApp').controller "ConfigureModalCtrl", ($scope, $modalInstance, primer3) ->
$scope.primer3 = primer3['data']
$scope.ok = ->
$modalInstance.close $scope.primer3
return
$scope.cancel = ->
$modalInstance.dismiss "cancel"
serverErrorHandler = ->
alert("There was a server error, please reload the page and try again.")
错误消息
Error: Unknown provider: ConfigureModalCtrlProvider <- ConfigureModalCtrl
类似的问题,但不能解决我的问题。How创建单独的AngularJS控制器中的文件?
所以,我怎么能解决这个问题,为什么这不是对其他(非模态实例)控制器发生的?是不是因为他们的路线被命名为?
So how can I resolve this problem, and why does this not occur for the other (non-modal instance) controllers? Is it because they are named in the routes?
在编码风格的任何建议,欢迎也...感谢阅读本。
Any recommendations on coding style are welcome also ... thanks for reading this.
尝试把控制器作为一个字符串 - 我有一个类似的问题。
Try putting the controller as a string -- I had a similar issue.
controller: 'ConfigureModalCtrl'