0
我遇到了ng級的問題。我想改變布爾值來控制ng-class,但是這個值被設置爲異步模式並且視圖文件剛剛被加載。沒有點擊的角度ng級更改
這是html的觀點
<li ng-class="{active: isPageView('media')}">
<div class="pointer" ng-show="isPageView('media')">
<div class="arrow"></div>
<div class="arrow_border"></div>
</div>
<a ng-class="{true: 'dropdown-toggle', false: ''}[disabled]" href="">
<i class="icon-camera-retro"></i>
<span>Media</span>
<i class="icon-chevron-down"></i>
</a>
<ul class="submenu">
...........
</ul>
</li>
,這是控制器的一部分
$scope.init = function(){
_.mixin(_.str.exports());
$scope.disabled = true;
$rootScope.emptyCompose();
var localstorage = localStorageService.get('Userprofiles');
var allExpired = true;
if (localstorage) {
$rootScope.userprofiles = localstorage;
_.each($rootScope.userprofiles, function(userprofile){
if(moment().isBefore(moment.unix(userprofile.expireTime))){
allExpired = false;
}
});
if(allExpired){
$scope.disabled = ! $scope.disabled;
$rootScope.modalInstance = $modal.open({
templateUrl: 'views/composebilling.html',
controller: 'BillingCtrl',
keyboard: false,
backdrop: 'static'
});
}
}else {
Index.query(function(userprofiles) {
$rootScope.userprofiles = userprofiles;
localStorageService.add('Userprofiles', userprofiles);
_.each($rootScope.userprofiles, function(userprofile){
if(moment().isBefore(moment.unix(userprofile.expireTime))){
allExpired = false;
}
});
if(allExpired){
$scope.disabled = ! $scope.disabled;
$rootScope.modalInstance = $modal.open({
templateUrl: 'views/composebilling.html',
controller: 'BillingCtrl',
keyboard: false,
backdrop: 'static'
});
}
});
}
如果$ scope.disabled過程中不會對服務器查詢設置好的所有火好,否則我有麻煩