Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

chechogrom's avatar

Validations for roles with angular at the frontend

Hello everyone, I am currently using angular to build the frontend of my application and I would like to give me feedback on how it can be the best option to validate according to the user's role show or hide menu options or buttons with actions.

constantly make request to the back asking for permits, localStorage...

I thank you in advance that you can give me a viable and safe idea.

0 likes
4 replies
jlrdw's avatar

I'd suggest watching the series where @jeffreyway made laravel an SPA. Granted not Angular, but many SPA techniques apply.

Myself, in a MPA rather than all that @can and if's, I find it easier to have an index page for users and a separate indexadmin page for admins. Just my preference. That way it avoids all that showing/ hiding.

Preference has a lot to do with it.

1 like
jstn's avatar

constantly make request to the back asking for permits, localStorage...

Typically each page request would return User API with permissions attached. That's what you base your validation off of.

1 like
chechogrom's avatar

@jstn Do you consider the most optimal and simple option to do it?

Thanks in advance

Please or to participate in this conversation.