Implementing Dynamic Views in Angular
Netanel Basal
8089

Netanel Basal simple and sweet article to explain edge cases as always. Good work.

In first example can sidebar component be written like this instead?

import { Component, AfterViewInit, ViewChild, ViewContainerRef } from ‘@angular/core’;

import { SidebarService } from ‘../sidebar.service’;

@Component({

selector: ‘app-sidebar’,

template: `

<div>

<ng-container #container></ng-container>

</div>

`

})

export class SidebarComponent implements AfterViewInit {

@ViewChild(‘container’, { read: ViewContainerRef }) container;

constructor( private _sidebarService : SidebarService ) {

}

ngAfterViewInit() {

this._sidebarService.vcr = this.container;

}

}

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.