前端:
<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>
点击后不会给p增加hover属性,想要达到的效果是,点击p给该p增加hover属性,不知道哪里弄错了,刚学angularjs,麻烦解答一下
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