【发布时间】:2023-06-24 00:02:01
【问题描述】:
像往常一样,我正在通过 Angular 填充我的 index.html。我有一个看起来像这样的索引:
<body>
<nav ng-include="'app/partials/navbar.html'" ng-controller="NavBarController"></nav>
<main>
<section ui-view="donate"></section>
<section ng-include="'app/partials/about.html'"></section>
<section ui-view="stories"></section>
<section ng-include="'app/partials/contact.html'"></section>
</main>
<footer ng-include="'app/partials/footer.html'"/>
</body>
我的nav、about、contact和<footer>都有静态内容,所以我用了ng-include。捐赠和故事<section>s 是动态的,所以我使用了ui-view。
问题
在涉及静态内容的情况下,使用ui-view 比使用ng-include 有什么优势吗? nav 使用 ui-view 可能会更好我可以在 $stateProvider.state() 中引用 NavBarController,但是静态部分呢?
【问题讨论】:
标签: angularjs angular-ui-router angularjs-ng-include