Activity Forums Salesforce® Discussions How to include Encapsulating component style in angular 2?

  • Archit

    Member
    March 29, 2018 at 12:32 pm

    For every Angular component you write, you may define not only an HTML template, but also the CSS styles that go with that template, specifying any selectors, rules, and media queries that you need.

    One way to do this is to set the styles property in the component metadata. The styles property takes an array of strings that contain CSS code. Usually you give it one string, as in the following example:

    @Component({
    selector: 'app-root',
    template: `
    <h1>Tour of Heroes</h1>
    <app-hero-main [hero]="hero"></app-hero-main>
    `,
    styles: ['h1 { font-weight: normal; }']
    })
    export class HeroAppComponent {
    /* . . . */
    }
    

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos