@Misiu wrote:
First off all I'd like to say that this is my first angular/ionic project so please understand my lack of knowledge
I'm trying to build a catalog like application, where user can see all items in dashboard view and when he clicks on item then application loads details about selected item and displays it in separate view.
My config function looks like this:
.config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider, $httpProvider) { $ionicConfigProvider.scrolling.jsScrolling(true); $httpProvider.interceptors.push('httpRequestInterceptor'); $stateProvider .state('login', { url: '/login', templateUrl: 'view.login/login.html', controller: 'LoginCtrl' }) .state('app', { url: '/app', abstract: true, templateUrl: 'view.app/app.html', controller: 'AppCtrl' }) .state('app.dashboard', { url: '/dashboard', views: { 'mainContent': { templateUrl: 'view.dashboard/dashboard.html', controller: 'DashboardCtrl', } } }) .state('app.details', { url: '/details/:itemId', views: { 'mainContent': { templateUrl: 'view.details/details.html', controller: 'DetailsCtrl', resolve: { playlist: function($stateParams, MyDataService) { var playlist = MyDataService.getDetails($stateParams.itemId); if (playlist === null) { console.log("not exists!"); } else { return playlist; } } } } } }); //default $urlRouterProvider.otherwise(function($injector) { var $state = $injector.get("$state"); $state.go("login"); }); });
When I click on item and MyDataService returns item I can see correct details view, but when I change last part of url from lest say 10 to 100 (id that is not correct) I get console.log("not exists!") but application still goes to details view (but it is empty).
Can I prevent route in resolve? I'd like to have error stare and whenever MyDataService isn't returning data I'd like to go to that state.Thanks for advice!
Posts: 1
Participants: 1