前端:
<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,麻煩解答一下
我把你的程式碼放到jsFiddle上了,改了一下,達到了你的要求,如果看不到效果就要翻牆了。
Demo,
把ng-class中的selected換成hover
把文檔好好看下