---
title: "Discussion on \"How I created a directive in Angular that renders components only if user is authorized?\" | Hashnode"
description: "Discussion on \"How I created a directive in Angular that renders components only if user is authorized?\". Recently, I was working on an Angular project where certain components were public meaning that everyone should see them and others should be rendered only if the user is authenticated or have a specific role, so I was doing something like this:\n<!--..."
url: "https://hashnode.com/posts/how-i-created-a-directive-in-angular-that-renders-components-only-if-user-is-authorized/63c6c1357feb3ddc54cbf049"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How I created a directive in Angular that renders components only if user is authorized?](https://potatoesblog.tech/how-i-created-a-directive-in-angular-that-renders-components-only-if-user-is-authorized?utm_source=hashnode&utm_medium=feed)

Recently, I was working on an Angular project where certain components were public meaning that everyone should see them and others should be rendered only if the user is authenticated or have a specific role, so I was doing something like this: <!--...

Jan 17, 2023 · 3 min read · potatoesblog.tech  
Read the article

-   [#angularjs](https://hashnode.com/tag/angularjs)
-   [#typescript](https://hashnode.com/tag/typescript)
-   [#angular-directive](https://hashnode.com/tag/angular-directive)
-   [#authorization](https://hashnode.com/tag/authorization)

## Written by

[Gassai Hamza](https://hashnode.com/@gassaihamza)

@gassaihamza

  
[View profile](https://hashnode.com/@gassaihamza)

programming

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
