利用angular给节点添加样式

<!DOCTYPE html>
<html lang="en" ng-app="myapp">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="../js/angularjs.js"></script>
    <style>
        body{
            font-size: 32px;
        }
        ul{
            list-style-type: none;
            width: 408px;
            margin:0px;
            padding: 0px;
        }
        ul .odd{
            color:#0026ff;
        }
        ul .even{
            color:#ff0000;
        }
        ul .bold{
            font-weight:bold;
            color:red;
        }
        ul li span{
            width: 52px;
            float:left;
            padding:0px 10px;
        }
        ul .focus{
            background: #cccccc;
        }
    </style>
</head>
<body>
    <div ng-controller="c2_ll">
        <ul>
            <li ng-class="{{bold}}">
                <span>1</span>
                <span>2</span>
                <span>3</span>
                <span>4</span>
                <span>5</span>
            </li>
            <li ng-class-even="even" ng-class-odd="odd" ng-repeat="stu in data" ng-click="li_click($index)" ng-class="{focus: $index==focus}">
            <span>{{$index+1}}</span>
            <span>{{stu.name}}</span>
            <span>{{stu.sex}}</span>    
            <span>{{$first?'是':'否'}}</span>
            <span>{{$last?'是':'否'}}</span>
            </li>
        </ul>
    </div>
</body>
<script>
    var app=angular.module('myapp',[]);
    app.controller('c2_ll',function($scope){
        $scope.bold="bold";
        $scope.li_click=function(i){
            $scope.focus=i;
        };
        $scope.data=[
        {name:"11",sex:"女"},
        {name:"22",sex:"女"},
        {name:"33",sex:"男"},
        {name:"44",sex:"男"}
        ]
    })
</script>
</html>

 

转载于:https://www.cnblogs.com/null11/p/6202929.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值