Angular注入了错误的$ modal?

时间:2014-10-21 14:42:34

标签: javascript angularjs dependency-injection modal-dialog angular-ui-bootstrap

我试图通过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。但是,这就是我所看到的:

This is not the $modal I was looking for!

这个模态对象有很多功能,而且都不是open。所以我猜测Angular正在向我的控制器注入错误的$ modal,但我不知道为什么或如何修复它。

0 个答案:

没有答案