angular.js - angular angular-ui-route里$state.includes 写这个不起作用

浏览:35日期:2022-12-20

问题描述

angular 里$state.includes 写这个不起作用

问题解答

回答1:

找到原因了,可能$scope作用域不够,应该用$rootScope

nameurl.controller.js

$rootScope.nameURL = $state.includes('nameURL.**');

这句话的意思是,所有nameURL和nameURL子页都会返回true

index.html

<li><a ui-sref='nameurl.about' ng-class='{active: nameURL}'>关于我们</a></li>

相关文章: