小编Cod*_*ner的帖子

bootstrap类未应用于角度2组件

这是我的第一个有角度的2应用程序,不知道为什么没有应用bootstrap类或者缺少glyphicons?有人可以解释如何在角度2中使用bootstrap类吗?

这是我的app.component.ts

import {Component} from 'angular2/core';
import {LikeComponent} from './like.component'

@Component({
    selector: 'my-app',
    template: `
                <like [totalLikes]="tweet.totalLikes" [iLike]="tweet.iLike"></like>
               `,
    directives: [LikeComponent] 
})
export class AppComponent {
    tweet = {
        totalLikes: 10,
        iLike: false
    }
 }
Run Code Online (Sandbox Code Playgroud)

和like.component.ts:

import {Component, Input} from 'angular2/core';

@Component({
    selector: 'like',
    template: `
    <i
       class="glyphicon glyphicon-heart" 
       [class.highlighted]="iLike"
       (click)="onClick()">
    </i>
    <span>{{ totalLikes }}</span>
    `,
    styles: [`
        .glyphicon-heart {
            color: #ccc;
            cursor: pointer;
        }
        
        .highlighted {
            color: deeppink;
        }   
    `]
})
export class LikeComponent {
    @Input() totalLikes = 0; …
Run Code Online (Sandbox Code Playgroud)

twitter-bootstrap-3 angular

5
推荐指数
1
解决办法
5901
查看次数

标签 统计

angular ×1

twitter-bootstrap-3 ×1