Reputation: 2645
I'm building an ionic app. The app has about 30 views. some of them are locked and to user isn't able to interact on them with a reason. If the user scanns a barcode the about 10 Views should be replaced with other content. It's not very much. It should be consistent after the scan. So a relaunch will show the unlocked content. Do I have to do this with CSS and hide/show, or is there a nicer solution for this?
Upvotes: 0
Views: 49
Reputation: 2516
If i would have to do this in ionic and angularJs.
I would have maintained an object or array of items/states that can be accesses.
Whenever i have to allow a user to access a state i would have added that state to allowed array/object so that it can be accessed.
Now if on same page i have to show content based on permissions i would have done something like below
<div ng-if="state | permissions ">
and my array would have been something like
var permissions = {
'all' :{'state':['home']},
'user' :{'state':['home','question'},
'admin':{'state':['home','admin','users']}
and filter could look like
.filter('permissions',function(){
return function(role){
return permissions[role].state
// implement contains functionality
}
});
Upvotes: 2