嗨,我正在尝试通过ng-class
. 如您所见,代码非常简单,但没有添加类:
app.run(function($rootScope, $location,$http,ngDialog,array_helper){
var update = function() {
/*CONFIG PARAMS*/
$rootScope.config = {};
$rootScope.config.app_routes = [
"/",
"/channels",
"/channels/create",
"/users",
"/auth/login",
"/auth/signup"
];
console.log($rootScope.config.app_url);
console.log($rootScope.config.app_routes.indexOf($rootScope.config.app_url));
};
$rootScope.$on('$routeChangeStart', function() {
update();
});
});
然后在视图中,我这样做:
<div ng-view ng-animate class="" ng-class="{'slide': config.app_routes.indexOf(config.app_url) == -1}"></div>
但它似乎永远不会起作用,因为它永远不会添加 class slide
。同时console.log
效果很好,只有在正确时才返回-1:O