How would you control size of an element on resize of the window in a component?
Answer / Shikha Rai
To control the size of an element on window resize in Angular 2, you can use the following approach:
1. Import the EventListener from @angular/core and declare it as a property in your component class.
2. Add the EventListener to the window object's 'resize' event using the nativeWindow.addEventListener() method.
3. Inside the resize event handler, calculate the new size of the element based on the current window dimensions.
4. Update the element's style or properties with the calculated values.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is angular good for?
Can you explain to $on and/or $watch ?
Can angular run without node?
What are differences between angular 4 and angular 2?
Explain webpack?
What is a component angular?
What is the use of a filter in angularjs?
Explain data binding in angular 4?
Write all the steps to configure an angular app(ng-app).
How to load select box during page initialization using AngularJS?
What is route snapshot?
What is the use of interceptors in angular 4?