AngularJS - Multiple ng-view in single template

后端 未结 6 1778
我寻月下人不归
我寻月下人不归 2020-11-29 17:38

I am building a dynamic web app by using AngularJS. Is it possible to have multiple ng-view on a single template?

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-29 18:13

    I believe you can accomplish it by just having single ng-view. In the main template you can have ng-include sections for sub views, then in the main controller define model properties for each sub template. So that they will bind automatically to ng-include sections. This is same as having multiple ng-view

    You can check the example given in ng-include documentation

    in the example when you change the template from dropdown list it changes the content. Here assume you have one main ng-view and instead of manually selecting sub content by selecting drop down, you do it as when main view is loaded.

提交回复
热议问题