I need dymanically in runtime hook child state to root state. Injection of $state
into service seems to be in place nevertheless $state.state
is evaluated as undefined
. But $state
returns valid object. How to fix it?
app.service('EntryStateUrlService', ['$state', '$q', '$http', function($state,$q,$http){
this.getEntryStateUrl = function(feeds) {
var deferred = $q.defer();
var idx = 0,
promises = [];
feeds.forEach(function(e) {
$http.jsonp(e.link).success(function(data) {
var generatedStateName = data.title;
$state.state('root.' + generatedStateName, // $state.state is evaluated
{ // as undefined
templateUrl : '/partials/article-view.html', // here taking template
controller: function($scope){ // controller to pass
$scope.title = data.title; // values to this template
$scope.author = data.author;
}
})
});
});
/*stuff*/
}
}]);