我试图通过Angular创建一个模态,但每当我运行该函数时,我都会收到以下错误:
TypeError: undefined is not a function
at h.root.RootController.$scope.openModal
以下(删节)代码:
RootController = ($scope, $http, $state, $modal) ->
$scope.openModal = -> $modal.open(
templateUrl: 'partials/modals/myModal.html'
controller: 'myModal'
)
看起来相当直接,但它不起作用。真正让我失望的是我在chrome中调试它的时候。根据{{3}},The $modal service has only one method: open(options)
。因此,当我在openModal
行上放置一个断点时,我希望看到只有一个属性的$modal
对象:open。但是,这就是我所看到的:
这个模态对象有很多功能,而且都不是open
。所以我猜测Angular正在向我的控制器注入错误的$ modal,但我不知道为什么或如何修复它。