大佬教程收集整理的这篇文章主要介绍了javascript – Angular UI-Router:URL已更改,但视图未加载,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
$stateProvider .state('parent',{ url: "/parent",views: { 'area1': {templateUrl : 'parentView.html'},'area2' : ... // some other areas + template } }) .state('parent.child1',{ url: "/child1",views: { 'area1' : {templateUrl : 'child1View.html'},'area2' : ... // still some other areas,not changing } }) .state('parent.child2',{ url: "/child2",views: { 'area1' : {templateUrl : 'child2View.html'},not changing } })
当使用该应用程序时,我将主视图分为某些区域.在第一个区域,我使用一个特定的html文件.如果我点击一个链接,应用程序将使用$state.go(‘myState’)进入一个小孩状态.那时,URL被更改,但是子视图没有加载到页面中.
我在网站上搜索了答案,我发现这个问题来自另外一个似乎遇到同样问题的问题:@L_696_0@
你知道我错过了什么吗?
对不起,英文不好
index.html很可能包含这些目标:
<body> <div ui-view="area1"></div> <div ui-view="area2"></div> ...
所以,如果父母和孩子都这样做,我们需要使用绝对命名:
.state('parent.child1',{ url: "/child1",views: { 'area1@' : {template : '<h2>child 1 area 1 </h2>'},'area2@' : {template : '<h2>child 1 area 2</h2>'},} }) .state('parent.child2',{ url: "/child2",views: { 'area1@' : {template : '<h2>child 2 area 1 </h2>'},'area2@' : {template : '<h2>child 2 area 2</h2>'},} })
我们来看一下doc:
View Names – Relative vs. Absolute Names
.state('report',{ views: { 'filters@': { },'tabledata@': { },'graph@': { } } })
所以,我们的孩子需要使用1)查看目标名称2)分隔符@和3)状态名称(在我们的字符串中为空表示根):’area1 @’
这些链接,类似于$state.go()现在将工作:
<a ui-sref="parent"> <a ui-sref="parent.child1"> <a ui-sref="parent.child2">
检查here
以上是大佬教程为你收集整理的javascript – Angular UI-Router:URL已更改,但视图未加载全部内容,希望文章能够帮你解决javascript – Angular UI-Router:URL已更改,但视图未加载所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。