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 does ng transclude do?
What is the tslint.json file used for?
How do you define a module?
What is resolve in angularjs?
What is routerstate in routers?
What are the directives available in router?
What is Data Binding? How Many Types Of Data Binding Directives Are Provided By AngularJS?
Can I use angularjs with php?
What is mvc application?
How to use foreach in angular js?
Explain the concept of lazy loading in angular 2
What is ngrx?