javascript - Click to add and delete classes in angularJs
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-06-08 11:02:15
0
2
794

$(".task-aot>p").on("click", function () {
$(this).addClass('active').siblings().removeClass("active")
});
Can the effect of this code be realized in Angular?

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(2)
学习ing

If it is angularjs (officially called angular1.0x version), there is an ngClass directive that can control whether the class value appears. The specific usage is as follows
<p ng-class {'selected': isSelected, 'car': isCar}">
</p>

You can use an ng-click to control a value, and then map this value to ng-class for control

漂亮男人

Wrong, you are asking a very common question in ng
For example, the li in ul is traversed, and each li has an $index value
Take a value such as target, the default is -1,
When you click li , let the target be equal to the index value of the current li,
The style judgment is roughly written like this, css: { selected: $index == target }

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template