我是 angularjs 的新手,我对 ng-include 和 $state.includes 之间没有什么混淆。谁能告诉我为什么我们使用 $state.includes 而不是 ng-include 指令?
最佳答案
假设您有一个带有一些子菜单的父菜单。对于每个子菜单,您都有类似这样的内容来添加事件类:
ui-sref-active="active"
但是当您导航到每个子状态时,您还需要为父菜单添加事件类。然后您可以使用ui-router
包含。
<li ng-class="{ active: state.includes('parentState') }">
注意:您必须将其添加到 Controller 中:
$scope.state = $state;
关于ng-include,与$state.include无关。它将外部 html 编译到指令中。
关于angularjs - AngularJS 中 $state.includes 的用途是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43511217/