0

I am facing one issue in angular 2 where I need to load HTML page based on user type is Admin or client user. The component file contains same functions and I don't want to repeat .ts file with same functions and handling the same event, but the HTML is different. I want to assign templateUrl based on user type.

templateUrl: './clientOperation-component.html'

With the above sample code I want to load templateURL based on a condition is it the Admin or client.

5
  • why not have a template and just hide elements based on the user's role? Commented Jun 24, 2017 at 15:39
  • That can resolve the issue but instead of validating the user for every div is not a feasible answer. In a page I need to check the condition around 20 times, So I wanted to put in a separate page where it checks once and render the HTML. Commented Jun 28, 2017 at 6:23
  • so you basically want to build 2 apps? One for Admin one for normal users? Commented Jun 28, 2017 at 6:58
  • Possible duplicate of Angular 2 component with multiple views Commented Jun 28, 2017 at 7:00
  • Thanks for the reply. I checked link which you shared here. It renders multiple views but my requirement is something different. I want to include that view based on condition and that is not working with this. Commented Jul 2, 2017 at 15:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.