Hi guys,
I’ve been going around an issue i’ve been working on, probably more of a angularjs question then an ionic.
I have a view that will show a list of deals and a deals detail view to see each specific deal. My question is, if I have only one deal I don’t want to show the list but go straight to the deal detail view.
I’ve specified both views in my state provider (deal and deal.detail). On the deal controller I check the data and decide if to show the list view or the detail list but If I only want to show the detail view it loads first the list and then goes straight to the detail view (I’m using $state.go)
Where should this be defined ? When I’m defining my states ? Or in the config module of the Deals ?
I’ll be posting a codepen soon with my issue
So I think I found a way to do this with state resolve http://learn.ionicframework.com/formulas/data-the-right-way/
But now I’m having a different issue. I’ve followed the tutorial but can’t seem to make it work. I get a unknown provider on state change
$stateChangeError event, toState, toParams, fromState, fromParams, error =>
Error: [$injector:unpr] Unknown provider: eProvider <- e
http://errors.angularjs.org/1.3.8/$injector/unpr?p0=eProvider%20%3C-%20e
My config module:
....
views[viewName] = {
templateUrl: '/at/core/features/' + featureName + '/' + capitalizedFeatureName + '.html',
controller: capitalizedFeatureName.concat('Ctrl')
};
var stateName = 'tab.'.concat(featureName);
var stateDefinition = {
cache: cacheContent,
url: '/'.concat(featureName),
resolve: {
item: function(featureData){
return featureData.getItem();
}
},
views: views
};
....
My FeatureData Service:
(function(){
'use strict';
angular
.module('featureData', [])
.service('featureData', featureData);
featureData.$inject = ['$q','atContent'];
function featureData($q,atContent) {
return {
getItem : getItem
}
function getItem(){
var dfd = $q.defer()
dfd.resolve(atContent.getFeatureJsonByName('contacts'));
return dfd.promise;
}
}
})();
What am I missing ?