Front end:
<p ng-app="ngApp" ng-controller="productPackagePullController">
<dl class="pd-dsc clearfix" id="pd-dsc1" style='margin-top:8px;'>
<dt class="left">{{sdata.spd1name}}: </dt>
<p class='pd-spec-dets clearfix'>
<p class='pd-spec-sb enable'
ng-class="{'selected':s._hover}"
ng-repeat="s in data"
ng-bind="s.det_name1"
ng-click="clickStatus(s)">
</p>
</p>
</dl>
</p>
js:
$scope.clickStatus = function(prop){
prop._hover = !prop._hover;
var text = prop.det_name1;
}
css:
<style type="text/css">
.pd-spec-sb {
font-size: 12px;
line-height: initial;
display: inline-block;
padding: 4px 6px;
border: 1px solid #ccc;
color: #aaa;
margin-right: 5px;
margin-bottom: 5px;
float: left;
}
.pd-spec-sb.enable {
color: #666;
border: 1px solid #666;
}
.pd-spec-sb.hover {
color: #ff9000;
border: 1px solid #ff9000;
}
</style>
After clicking, the hover attribute will not be added to p. The desired effect is that clicking p will add the hover attribute to the p. I don’t know where I made a mistake. I just learned angularjs, please give me an answer
I put your code on jsFiddle and made some changes to meet your requirements. If you don’t see the effect, you have to jump over the wall.
Demo,
Replace selected in ng-class with hover
Read the document carefully