class/style 屬性值的處裡

1 篇文章 / 0 new
author
class/style 屬性值的處裡
1. 事件模式
$scope.clickEvent = function(event) {
    if ($(event.target).hasClass('active')) {
        $(event.target).removeClass('active');
    } else {
        $(event.target).addClass('active');
    }
};
<p ng-click='clickEvent($event)'>...</p>
2. 直接崁入
<p ng-class="{active: data.selected}">...</p>
3. Style
<p ng-style="{myStyle}" ng-click="myStyle={color:'red'}">...</p>
Free Web Hosting