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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745279431a4620207.html
评论列表(0条)