angular-ui-router嵌套状态不适用于多个视图

时间:2022-06-16 19:38:53

Trying to make nested views work, but can't understand where i'm doing wrong. I have parent view with navigation and content, and when user click navigation links, it should load correct view. For some reason it still shows default content.

试图使嵌套视图工作,但无法理解我在哪里做错了。我有导航和内容的父视图,当用户单击导航链接时,它应该加载正确的视图。出于某种原因,它仍然显示默认内容。

There are separate login and error states with views, but i removed them to make example simpler.

视图有单独的登录和错误状态,但我删除它们使示例更简单。

Here is plunker: http://plnkr.co/edit/bvcNzDwSanPkVm1zASVe?p=preview

这里是plunker:http://plnkr.co/edit/bvcNzDwSanPkVm1zASVe?p =preview

So when user click on link, he should see template of selected state loaded to unnamed ui-view.

因此,当用户点击链接时,他应该看到所选状态的模板被加载到未命名的ui-view。

1 个解决方案

#1


2  

Finally got it solved. I have to put additional ui-view to default view:

终于解决了。我必须在默认视图中添加额外的ui-view:

'': {
      template: '<div ui-view></div>'
    },

Here is working plunker: http://plnkr.co/edit/zy4mYR?p=preview

这是工作的plunker:http://plnkr.co/edit/zy4mYR?p = preview

#1


2  

Finally got it solved. I have to put additional ui-view to default view:

终于解决了。我必须在默认视图中添加额外的ui-view:

'': {
      template: '<div ui-view></div>'
    },

Here is working plunker: http://plnkr.co/edit/zy4mYR?p=preview

这是工作的plunker:http://plnkr.co/edit/zy4mYR?p = preview