我正在尝试在加载 Controller 之前解析一些数据。在开发代码上按预期工作,但是当我缩小它时,我的 $http
被替换为 e
或任何可用的变量。
我无法在 angular.module("app", []).config
中注入(inject) $http
。所以我不知道如何解决这个问题。
angular.module("app", [
"app.controllers"
"app.directives"
"app.filters"
"app.services"
]).config ($stateProvider, $urlRouterProvider) ->
$stateProvider.state("tab",
url: "/tab"
abstract: true
templateUrl: "tpls/tabs.html"
)
.state("tab.programs",
url: "/programs"
abstract: true
resolve:
events: ($http) -> # $http get's replaced upon minification..
$http.get('my.example.site/events.json')
.then((data) ->
data.data
)
最佳答案
好的,我已经弄清楚了。
我必须将它注入(inject)函数本身。像这样:
.state("tab.programs",
url: "/programs"
abstract: true
resolve:
events: ['$http', ($http) -> # $http now is injected
$http.get('my.example.site/events.json')
.then((data) ->
data.data
)
]
关于javascript - AngularJS UI-Router,解决 $http 依赖在 minify 时丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22834265/