Reloading only child state

元气小坏坏 提交于 2020-01-06 14:27:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!