I use bootstrap for my layout and I need to check if the automatic calculated size of my DIV with bootstrap for example width = 25% is changed.
Is there a possibility to do change detection on a attribute which I don't set in my template, but is set by bootstrap. (window:resize) is not enough.
thx
I had the same problem so I used the lightweight library called Angular-Resize-Event
https://www.npmjs.com/package/angular-resize-event
After installing it just add this output event to any div which you want to check for size changes.
I have tried the correct answer but the refresh rate wasn't very accurate, So I looked for another solution.
Here it is
Then you can use it in any element like:
There are few methods to track DOM attribute changes:
setInterval
DOMAttrModified
+propertychange
for IEMutationObserver
You can add a directive to the
div
and implement lifecycle hookngDoCheck()
to perform your own change detection logic. You'll need to injectElementRef
:If the
div
is inside a component template, add a local template variableThen use
@ViewChild()
to get a reference to thediv
and implement lifecycle hookngDoCheck()
orngAfterViewChecked()
to perform your own change detection logic.Note that ngDoCheck() and ngAfterViewChecked() will be called every time change detection runs. See also the dev guide Lifecycle Hooks.