重新加载唯一的孩子状态 [英] Reloading only child state

查看:84
本文介绍了重新加载唯一的孩子状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有嵌套的UI状态.我只想加载子状态而不是父状态.

I have nested UI states. I want to load only child state not the parent state.

儿童状态:

$stateProvider.state('app.test', {
    url: '^/test?search',
    controller: 'TestController',
    templateUrl: 'test/test.tpl.html',
    pageTitle: 'Tests',
 });

父母的国家:

 $stateProvider.state('app', {
    url: '/app',
    abstract: true,
    templateUrl: 'parent/main-content.tpl.html',
    controller: 'ParentController'
 })

当我尝试使用

 $state.go('.', {search: searchTerm});

仅加载子状态.

当我尝试$state.reload();时,它会同时加载状态和控制器. 如果我没有用于状态的 searchTerm 参数,那么如何仅加载当前状态?

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 ?

推荐答案

使用 $ state.reload('childstate')或$ state.go('state',{params}, {reload:"childstate"} )

use $state.reload('childstate') or $state.go('state',{params},{reload: "childstate"})

这将完成您需要的工作.

This will do the stuff you needed.

这篇关于重新加载唯一的孩子状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆