Angular2 sub templates?

Is there any way to have multiple templates or sub templates for a specific component in angular2 ?

typescript file – >

@Component({
    selector: 'portal',
    templateUrl: 'main.html'
})

export class AppComponent{}

main.html – >

<div>
<div>bla bla bla </div>
   -- load sub html page ??????
<div>

2
Leave a Reply

avatar
2 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Jason Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Jason
Guest

I would use a component for this since Angular2 provides a component-based approach:

<div>
<div>bla bla bla </div>
   <someOtherComponent></someOtherComponent>
<div>

with the following code:

@Component({
  selector: 'someOtherComponent',
  templateUrl: 'other.html'
})
export class SomeOtherComponent{}

Jason
Guest

This is currently not supported but there are plans to add support eventually. The original approach using the @View() decorator was dropped though (See also https://github.com/angular/angular/issues/7363). You can use ngSwitch or ngIf to switch between different parts of a single template. >=RC.2 template: ` <div [ngSwitch]="value"> <div *ngSwitchCase="phone"> phone content here </div> <div *ngSwitchCase="tablet"> table content here <div *ngSwitchDefault> brower content here </div> </div> ` <=RC.1 template: ` <div [ngSwitch]="value"> <div *ngSwitchWhen="phone"> phone content here </div> <div *ngSwitchWhen="tablet"> table content here <div *ngSwitchDefault> brower content here </div> </div> `