Dr.*_*all 0 javascript twitter-bootstrap angularjs angular-ui angular-ui-bootstrap
我正在尝试向我的工厂注入一个bootstrap-ui $ modal服务,但是当我这样做时,我得到一个循环依赖问题,而当我没有定义$ modal时.代码如下:
retryModule = angular.module('g4plus.retry-call', ['ui.bootstrap'])
retryModule.factory 'RetryCall', ($q, $rootScope)->
requests = {}
failedRequests = {}
uniqueId = 0
modalInstance = undefined
modalClose = true
### Some more code
alertUser = ()->
modalInstance = $modal.open
template: """
<div class="modal-dialog">
... Some more code ...
Run Code Online (Sandbox Code Playgroud)
我如何在工厂内使用$ modal?请不要让我把这个代码放在一个指令中,因为这会破坏目的.如果我能把它放在一个指令中,我就已经完成了这个项目.控制器也是如此.
谢谢!
如果我将$ modal注入我的工厂,循环依赖性错误是:
未捕获错误:[$ injector:cdep]找到循环依赖项:$ modal < - RetryCall < - $ http < - $ compile
接受的答案没有提供有效的解决方案.
这里的问题$modal取决于$http.在拦截器中$modal不能要求$http因为$http还不存在(因为你仍处于配置阶段,配置$httpProvider).
用户thaumant的这个答案解释了如何解决这个问题,这里:
我需要两个AngularJS $ http服务实例或者什么?
| 归档时间: |
|
| 查看次数: |
2737 次 |
| 最近记录: |