2016년 1월 13일 수요일

[AngularJS] 형광펜 효과

Demo


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<html ng-app='fruitApp'>
    <head>
        <!-- 한글 설정 -->
        <meta charset="utf8">
        <title>angularjs test</title>
        <style type='text/css' rel='stylesheet'>
            .selected{
                background-color: lightgreen;
            }
       </style>
    </head>
    <body>
        <div ng-controller='fruitTableController'>
            <table>
                <tr ng-repeat='fruit in fruits' ng-click='selectFruit($index)' 
                ng-class='{selected : $index==selectedRow}'>
                    <td>{{fruit.name}}</td>
                    <td>{{fruit.price}}</td>
                </tr>
            </table>            
        </div>
        <script src='http://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js'></script>
        <script type='text/javascript'>
            var app = angular.module('fruitApp',[]);
            function __fruitTableController($scope){
                $scope.fruits=[
                    {name:'banana',price:'5000'},
                    {name:'apple',price:'3000'},
                    {name:'tomato',price:'4000'},
                ];
                $scope.selectFruit = function(index){
                    $scope.selectedRow= index;
                }
            }
            app.controller('fruitTableController',__fruitTableController);
       </script>
    </body>
</html>
cs

댓글 없음:

댓글 쓰기