typescript 重用能够组分

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了typescript 重用能够组分相关的知识,希望对你有一定的参考价值。

import {Component, Input} from '@angular/core';

@Component({
    selector: "reuse-able-component",
    template: `
        <!-- Main component for a primary marketing message or call to action -->
        <div class="jumbotron">
            <h1>{{ title.title }}</h1>
            <p>{{ title.description }}</p>
            
            <i class="glyphicon"
                [class.glyphicon-star-empty]="!isFavorite"
                [class.glyphicon-star]="isFavorite"
                (click)="onclick()">
            </i>
                

        </div>
        `
})

export class ReUseAbleComponent {
    @Input() isFavorite = false;

    onclick() {
        this.isFavorite = !this.isFavorite
    }    

    // Tilte and description of component

    title = {
        title: "Re-Use-Able Component",
        description: "Reuseable component in angular 2. Click on star to see changes. And if you want to see reuse of this component then click on two way binding on menu"
    }

}

以上是关于typescript 重用能够组分的主要内容,如果未能解决你的问题,请参考以下文章