$(".task-aot>p").on("click", function () {
$(this).addClass('active').siblings().removeClass("active")
});
Can the effect of this code be realized in Angular?
学习ing2017-06-08 11:04:15
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
漂亮男人2017-06-08 11:04:15
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 }