How to use styleurls and styles in angular 2?
Answer / A. Vinoth Saravanan
In Angular 2, you can define CSS using the `styles` property for inline styles or the `styleUrls` property for external stylesheets. To use them, follow these steps:
1. Declare the component and add the styles or styleUrls:
```typescript
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `<h1>Hello World!</h1>`,
styles: [`h1 { color: red; }`],
styleUrls: ['styles.css']
})
export class AppComponent {}
```
2. Create the external CSS file (styles.css) and define your styles there.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is nginclude?
What are constructors in angular?
What is provider?
Is angular a oop?
How can someone make an ajax call using angularjs?
What happens when the page containing angular based application loads?
what is the difference between a module’s forroot() and forchild() methods and why do you need it?
Explain factory method in angularjs?
What is a template in angular7?
What does a router.navigate do?
What are http interceptors?
How did we work with multiple modules in our project?