angularpermissionsauth-guard

Read/Write only permissions in Angular by route


Currently i have the type of permission on a service and i want to set read-only by path. Is there any way to do it? Something like the auth guard.

Thx

EDIT

Sidebar:

Section1
 link1p
 link2p
Section2
 link1x
 link2x

An example of my database response

Acces: Read
Section: Section1 
subSection: link1p

And now i want disable all forms in this component (link1p) by route, if it possible.


Solution

  • You can use the data property of the Route interface. You can pass whatever object you like to this, so utilizing it to set a read-only property is easy. Just set it up in your Routes array, then get it from the ActivatedRouteSnapshot whereever you need it

    const routes: Routes [
        {
            path: 'myReadOnlyRoute'
            data: { readOnly: true }
        }
    ]