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.

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
Pramod B
  • 1
  • 1
  • why not have a template and just hide elements based on the user's role? – toskv Jun 24 '17 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. – Pramod B Jun 28 '17 at 06:23
  • so you basically want to build 2 apps? One for Admin one for normal users? – toskv Jun 28 '17 at 06:58
  • Possible duplicate of [Angular 2 component with multiple views](https://stackoverflow.com/questions/31847001/angular-2-component-with-multiple-views) – toskv Jun 28 '17 at 07: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. – Pramod B Jul 02 '17 at 15:29

0 Answers0