Jquery 如何在数据更改时`$watch`并从`DOM'中删除类名`
在我的场景中,我有活动标题。当用户点击其他字幕时,我在它之间交换数据 单击Jquery 如何在数据更改时`$watch`并从`DOM'中删除类名`,jquery,html,angularjs,Jquery,Html,Angularjs,在我的场景中,我有活动标题。当用户点击其他字幕时,我在它之间交换数据 单击子标题时,我正在添加一个类名更新。当更新发生时,我需要在active指令中观察它,并且需要再次删除update类 如何做到这一点 我的HTML: <div class="wrapper" ng-app="myApp"> <div class="content" ng-controller="main"> <active-title></active-titl
子标题
时,我正在添加一个类名更新
。当更新发生时,我需要在active
指令中观察它,并且需要再次删除update
类
如何做到这一点
我的HTML:
<div class="wrapper" ng-app="myApp">
<div class="content" ng-controller="main">
<active-title></active-title>
<sub-title item='item' index=$index ng-repeat="item in items" change="changeItem"></sub-title>
</div>
</div>
由于您没有为指令创建作用域,并且在模型中有一个点,所以您可以直接从指令中查看它
scope.$watch('activeItem.name', function (newValue, oldValue) {
console.log(newValue)
})
scope.$watch('activeItem.name', function (newValue, oldValue) {
console.log(newValue)
})