angular.js - angularjs ng-class指令改变ng-click点击的class属性失效
巴扎黑
巴扎黑 2017-05-15 17:03:59
0
2
704

前端:

<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,麻烦解答一下

巴扎黑
巴扎黑

reply all(2)
小葫芦

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template