Search code examples
javascriptangularangular2-components

Angular 2 - is there any way to completely re-initialize a component upon resize window?


I have a component ComponentA. there is some dom manipulation for deferent devices. I don't wanna fix them for every device when the browser resized.

that's why I wanna re-initialize the whole component again. is there any way to do it?

or any other solution would be very helpful.

thank you in advance. :)


Solution

  • There is no way to programatically destroy or re-initialize an component in Angular. An component will automatically be destroyed if there are no more variables or DOM elements referencing it.

    EDIT: In order to solve your problem I'd suggest you have a look into the code nikolayandr posted.