Angularjs 点击文字改变背景色

来源:互联网 发布:qq空间做淘宝客2016 编辑:程序博客网 时间:2024/05/16 08:43

效果图:这里写图片描述
作者:Easy
链接:https://zhuanlan.zhihu.com/p/22233323

css 样式

.selected{
background-color:#C6E2FF;
}

html 列表是遍历出来的

<li   class="text-c" style="margin:10px;"  ng-repeat="item in dataList |filter:name" ng-class='{selected:$index==selectedRow}' ng-click='selectedWhich($index)'>    <a style="text-decoration:none;font-size:10px;" ng-bind="item.groupName">    </a></li>

js 方法主要是判断列表的哪一项被选中
$scope.selectedWhich = function (row) {

    $scope.selectedRow = row;

}
希望对你能有帮助!

0 0
原创粉丝点击