I have a device service and a device controller. First, time whenever the controller is called, I invoke setter method to set a boolean value. I want to change that value when the logout function is called which is in different service. My Device Service
define([], function () {
'use strict';
var DeviceService = [
"AuthService",
function (AuthService) {
var Device_Create = false;
return {
setUserCreatePermission :function () {
if(AuthService.checkForPermission('Device_Create')){
Device_Create = true;
}
},
getUserCreatePermission : function () {
return Device_Create
}
}
}];
return DeviceService;
})
My Device Controller has a init method which calls the setter method in device service. I have set a scope variable. If it set, it will call the method otherwise not.
define([], function () {
'use strict';
var DeviceListCtrl = ["$rootScope", "$scope", "DeviceService",
function ($rootScope, $scope, DeviceService) {
//variables
$scope.deviceList_init = true;
$scope.Device_Create = false;
init();
if(DeviceService.getDeviceCreatePermission()){
$scope.Device_Create = true;
}
function init() {
if($scope.deviceList_init){
DeviceService.setDeviceCreatePermission();
}
$scope.deviceList_init = false;
}
}]
return DeviceListCtrl;
});
Can someone help me ? TIA. I am new to this