admin管理员组文章数量:1417653
I'm trying to resolve some data before the controller get's loaded. Works as expected on development code, but when I minify it, my $http
get's replaced by e
or whatever variable is available.
I can't inject $http
in the angular.module("app", []).config
. So I have no idea how to solve this problem.
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
)
I'm trying to resolve some data before the controller get's loaded. Works as expected on development code, but when I minify it, my $http
get's replaced by e
or whatever variable is available.
I can't inject $http
in the angular.module("app", []).config
. So I have no idea how to solve this problem.
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
)
Share
Improve this question
asked Apr 3, 2014 at 10:04
Martin BroderMartin Broder
3351 gold badge7 silver badges21 bronze badges
2 Answers
Reset to default 5Ok I've figured it out.
I have to inject it on the function itself. Like this:
.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
)
]
Coffeescript makes my brain hurt, but in Javascript you'd do
config(['$stateProvider', function($stateProvider) {
...
}]);
That is, an array
containing your all dependencies as strings
(in order) and then the function
to run.
The minimizer won't mess with the strings, and Angular's DI framework understands that syntax.
本文标签: javascriptAngularJS uirouterresolve http dependency is lost upon minifyStack Overflow
版权声明:本文标题:javascript - AngularJS UI-Router, resolve $http dependency is lost upon minify - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745279431a2651352.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论