0

I use renderer of angular 4 to change DOM of some element. How can i know when the DOM finish render to call other method like this

this._renderer.setElementStyle(this._tileElement, 'width', '100%');
this._renderer.setElementStyle(this._tileElement, 'height', '100%');       

this._tile.viewport.scale = this._imageProcessing.calculateZoomRatioFullImage(this._tile.viewport,
              this._tileElement.clientWidth, this._tileElement.clientHeight);
this._tile.viewport.realSizeRatio = this._imageProcessing.calculateRealSizeRatio(this._tile.viewport);
this.render(this._tile);

Thanks you

Gurwinder Singh
  • 38,557
  • 6
  • 51
  • 76
BaoBao
  • 299
  • 1
  • 5
  • 15
  • It's done when the call returns (this doesn't apply if you change the model and depend on Angular updating the binding). There is no such think like DOM rendering finished in Angular. There are some lifecycle callback like `ngAfterViewInit()`, but that won't help you with imperative code like above. – Günter Zöchbauer Sep 18 '17 at 12:53
  • by using renderer you ll invite more troubles instead use ViewChild with event mentioned above by @GünterZöchbauer – nikhil mehta Sep 18 '17 at 12:55
  • Using `@ViewChild` and bindings is usually a better way than accessing the DOM. nikhil mehta is right about that. – Günter Zöchbauer Sep 18 '17 at 12:57
  • @nikhilmehta how can i use viewchild to change width height of element sir? – BaoBao Sep 18 '17 at 13:04
  • have a look at [this](https://stackoverflow.com/questions/32693061/angular-2-typescript-get-hold-of-an-element-in-the-template). But may I know why are you not using classes or ngClass or [style] for this – nikhil mehta Sep 18 '17 at 13:11

0 Answers0