我有一個導航下拉菜單,我想根據工廠的值隱藏下拉菜單中的一些選項。我正在使用ng-show
來選擇要隱藏或顯示基於工廠值的選項。設置false爲範圍變量在工廠設置時不起作用
當我將它設置爲false而沒有工廠時,它的工作原理和我在下拉菜單中看不到這些選項。
這是我從廠家得到的數據:
$scope.mstrClientLStatus=userDetailsFactory.getUserDetailsFromFactory().mstrClientLStatus;
console.log($scope.mstrClientLStatus)
//it is false but doesn't hide
當我設置上面false
直接的選項是隱藏的。
$scope.mstrClientLStatus= false //works and the options are hidden
我console.log
下一行的$scope.mstrClientLStatus
,這是假的,但它仍然顯示在下拉菜單中的選項。
的HTML:
<li ng-show="mstrClientLStatus"> //this is what I want to hide
整個工廠代碼:
.factory('userDetailsFactory',function(){
var user = {};
return {
setUserDetailsInFactory : function(val,$cookies,favoriteCookie,put,get){
user.useridFromSession = val[0].UserId;
user.usernameFromSession = val[0].UserName;
user.userroleFromSession = val[0].Role;
user.clientidFromSession = val[0].ClientId;
user.ip = "http://192.168.2.100:5000";
user.mstrDashBoardSession = val[0].DashBoard;
user.mstrClientLSession = val[0].ClientLogin;
user.ClientRegistrationSession = val[0].ClientRegistration;
user.mstrBustypeSession = val[0].mstrBustype;
user.mstrBusCategorySession = val[0].mstrBusCategory;
user.mstrSeatLayoutSession = val[0].mstrSeatLayout;
user.mstrDesignationSession = val[0].mstrDesignation;
user.mstrBusSession = val[0].mstrBus;
user.mstrRouteSession = val[0].mstrRoute;
user.mstrBranchSession = val[0].mstrBranch;
user.mstrDeviceSession = val[0].mstrDevice;
user.mstrServiceSession = val[0].mstrService;
user.mstrRouteFareSession = val[0].mstrRouteFare;
user.mstrNewUserSession = val[0].mstrNewUser;
user.mstrPDAServiceAssignSession = val[0].mstrPDAServiceAssign;
user.mstrUserRightSession = val[0].mstrUserRight;
user.rptTripSheetSession = val[0].rptTripSheet;
user.rptTripSummarySession = val[0].rptTripSummary;
user.rptCargoSummaryFromSession = val[0].rptCargoSummary;
user.rptBusMonthSession = val[0].rptBusMonth;
user.rptDeviceSession = val[0].rptDevice;
//console.log(user.useridFromSession);
//console.log(user.usernameFromSession);
//console.log(user.userroleFromSession);
},getUserDetailsFromFactory : function(){
return user;
}
};
嘗試'$範圍$適用()''中'$ scope.mstrClientLStatus = userDetailsFactory.getUserDetailsFromFactory()mstrClientLStatus的底部; ' – itzMEonTV
我得到這個錯誤'https://docs.angularjs.org/error/$rootScope/inprog?p0 = $ digest' – Abhi
你可以發佈你的工廠片段嗎? – Siddharth