1

I just want to configure my dashboard according to the user role .

for example

  1. if the user login have the role = admin , than the dashboard component should load the template URL which is for the admin.
  2. similarly if the user login have the role = employee , than the dashboard component should load the template URL which is for the employee.

in short i am saying that i have one component namely dashboard , and i want to load three different template URLs at three different time on three different roles

Is it possible in angular 2 ? and how .

faizan
  • 109
  • 7
  • Possible duplicate of [Angular 2 can one component have multiple templates?](https://stackoverflow.com/questions/39248159/angular-2-can-one-component-have-multiple-templates) – Kld Oct 18 '17 at 20:04

1 Answers1

0

No it is not possible to switch template URL at run time.

But you may try below for your use case,

<div [ngSwitch]="role">
   <ng-template [ngSwitchCase]="admin">...</ng-template>
   <ng-template [ngSwitchCase]="employee">...</ng-template>
</div>
Madhu Ranjan
  • 17,334
  • 7
  • 60
  • 69