ng-class in Angular2

前端 未结 5 1443
陌清茗
陌清茗 2020-12-14 15:32

I am developing a test application in angular 2 and I\'m stuck with a problem of adding classes based on list from model.

In Angular 1 one could do:

         


        
5条回答
  •  被撕碎了的回忆
    2020-12-14 15:36

    Using typescript and Angular 2 beta, ngClass doesn't seem to work. From following the API preview - https://angular.io/docs/ts/latest/api/common/NgClass-directive.html

    template: '
    Class Map
    '

    The example from Google provides two versions of code (which I assume is Alpha and updated to Beta). The new syntax in the website example doesn't seem to work... any ideas?

    @View({
        template: `
            

    completed

    `, directives: [NgClass, QuestionSection], })

提交回复
热议问题