0
在我的AngularJS應用程序中,我有以下路線,其中我保存數組中每條路線的權限級別,如下面的代碼所示。然後,我使用下面的代碼檢查當前登錄的用戶是否具有與要加載的路由相匹配的權限級別,但即使登錄的用戶權限與plevel數組中的某個權限相匹配,我也總是得到結果-1。有人可以檢查我的代碼,並告訴我我到底做錯了什麼,以及如何解決它?謝謝。Javascript正在檢查數組值總是返回-1
$routeProvider.when('/clients/new-invoice',
{ templateUrl: 'templates/new-invoice.html',
controller: 'InvoicesController',
title: 'New Invoice',
data: {
auth: true,
plevel: [5, 6, 8]
}
});
$rootScope.$on("$routeChangeStart", function(event, next, current) {
var CContent = $.cookie('UCookie');
console.log('User - permission match : ' + $.inArray(CContent, next.data. plevel));
});
我很好奇,你有什麼瀏覽器支持? –
@BenjaminGruenbaum所有流行瀏覽器 – MChan
這並沒有回答我的問題,但是meh。 –