问题
I have nested UI states. I want to load only child state not the parent state.
Child State :
$stateProvider.state('app.test', {
url: '^/test?search',
controller: 'TestController',
templateUrl: 'test/test.tpl.html',
pageTitle: 'Tests',
});
Parent State :
$stateProvider.state('app', {
url: '/app',
abstract: true,
templateUrl: 'parent/main-content.tpl.html',
controller: 'ParentController'
})
When I try to load only child state in test page using
$state.go('.', {search: searchTerm});
It loads only child state.
And when I try $state.reload();
, it loads both state and so there controllers.
If I don't have searchTerm parameter for state, then how can I load only current state ?
回答1:
$state.go($state.current) will do that
回答2:
use $state.reload('childstate') or $state.go('state',{params},{reload: "childstate"})
This will do the stuff you needed.
来源:https://stackoverflow.com/questions/37543098/reloading-only-child-state