Reputation: 909
Trying to leverage AngularJS UI States and using resolves to set vars. I currently have this in my app.js --
var stateConfig = ['stateHelperProvider', function(stateHelperProvider) {
stateHelperProvider
.state({
name: 'events',
url: '/' + artistSlug,
templateUrl: "/templates/events/events.html",
controller: "EventsCtrl",
resolve: {
artist: function(artist) {
return artist.getArtist();
}
}
});
Within the EventsCtrl I have the following --
angular.module('artist.events.controllers', []).
controller('EventsCtrl', ['$filter', '$rootScope', '$scope', '$state', '$stateParams', '$location', 'artist', function($filter, $rootScope, $scope, $state, $stateParams, $location, artist) {
$scope.artist = artist;
On my local dev machine, it resolves correctly. Within prod however, $scope.artist returns nothing. I believe it could be related to compiling based on precompiling and minification. Unsure how to fix though. Thoughts?
Upvotes: 2
Views: 482
Reputation: 164798
Unless you're using a build tool like ng-annotate, you will have to provide the DI annotation for the resolve
properties, ie
resolve: {
artist: ['artist', function(artist) {
return artist.getArtist();
}]
}
I would consider renaming your resolve property so it is different to your artist
service. At least that way, you would have gotten an error about an unresolved provider. Something like eventArtist
would be my pick.
Upvotes: 2