angular - Generic solution for disabling fields for non-authorized users -
i have project client side language angular 2. application has few pages , of them have different permissions. example, have employees page, books page, locations page, clocking page, etc.
each of pages has canedit , canview permissions. logged in user may have canedit permission locations, may not have canedit permissions books page.
i want make generic solution write on 1 place , work pages, don't want repeating code in pages. like: if user has canedit permissions current page, remove read-only attribute inputs, , if doesn't have canedit permissions, add read-only attribute.
at moment there no roles in project i'm open suggestions.
is possible done?
the best solumtion can imagine create service status of canedit , canview of user. then, on html page, use :
<button *ngif="userservice.canview">a button</button>
to show/hide (in fact, make exist or not) elements want displayed
Comments
Post a Comment