I have a navigation dropdown and I want to hide some of the options in the dropdown based on a value from a factory. I am using ng-show
on the options that I want to hide or show based on the value from factory.
When I set it to false directly without the factory it works and I don't see those options in the dropdown.
This is how I get the data from factory:
$scope.mstrClientLStatus=userDetailsFactory.getUserDetailsFromFactory().mstrClientLStatus;
console.log($scope.mstrClientLStatus)
//it is false but doesn't hide
When I set the above to false
directly the options are hidden.
$scope.mstrClientLStatus= false //works and the options are hidden
I console.log
the $scope.mstrClientLStatus
in the next line and it is false but it still shows the options in the dropdown.
The html:
<li ng-show="mstrClientLStatus"> //this is what I want to hide
The entire factory code:
.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;
}
};