AngularJS ui-router initial route -
i have page contains 2 different sub-pages.
the search
state main container , search.list
automatically when loads.
when user navigates search.detail
invoke last route till contained within search
main frame.
problem can't search.list
load default.
$stateprovider.state('search', { url: '/search/{appid}{reportid:(?:/[^/]+)?}', templateurl: 'app/search/search.tpl.html', controller: 'searchctrl', resolve: { app: function($stateparams, appsmodel) { return appsmodel.findone($stateparams.appid); } } }); $stateprovider.state('search.list', angularamd.route({ controller: 'listctrl', templateurl: 'app/search/list/list.tpl.html' })); $stateprovider.state('search.detail', { url: '/detail/{recordid}', title: "search", views:{ '': { templateurl: 'app/search/detail/detail.tpl.html', controller: 'detailctrl' }, 'grid@search.detail': { controller: 'listctrl', templateurl: 'app/search/list/list.tpl.html' }, 'record@search.detail': { templateurl: 'app/record/views/record.html', controller: 'recordctrl' } } } });
if move url , app
resolve attribute search.list
main container doesn't app
resolved needs render.
if move url attribute to search.list
search
not have appid
attribute in $state
resolve that.
in search controller added:
if(!$state.is('search.detail')) $state.go('search.list');
but works on first page load, if goto detail , go doesn't load list because controller re'initd. ideas?
ended consolidating search
, search.list
1 like:
$stateprovider.state('search', { url: '/search/{appid}{reportid:(?:/[^/]+)?}', title: "search", cssclass: 'searchctrl listctrl', views:{ '': { controller: 'searchctrl', templateurl: 'app/search/search.tpl.html', }, '@search': { controller: 'listctrl', templateurl: 'app/search/list/list.tpl.html' } }, resolve: { app: function($stateparams, appsmodel) { return appsmodel.findone($stateparams.appid); } } });
Comments
Post a Comment