2016년 1월 26일 화요일

[AngularJS] ngClass

css를 사용하는 클래스

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
43
44
45
<!DOCTYPE html>
<html >
  <head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css">
    <style>
    .padding5 {
      padding:15px;
      border: 1px dotted blue;
    }
    .boldText {
      font-weight: bold;
    }
    .redFill {
      color: red;
    }
    </style>    
  </head>
  <body ng-app>
  <div class="panel panel-primary">
    <div class="panel-heading">ngClass </div>  
      <div class="panel-body">
          <!-- css의 클래스를 지정하는데 angularJS의 boolean값을 이용할 수 있다. -->
        <p ng-class="{padding5: false, boldText:true, redFill:true}">Map Syntax Example</p>
       </div>
      <!-- check box에 응용하면, model에 연결해서 값을 변경할 수 있다. -->
      <div class="panel-body">
          <p ng-class="{padding5: padding, boldText:bold, redFill:red}">Map Syntax Example</p>
          <input type="checkbox" ng-model="padding"> Padding <br>
          <input type="checkbox" ng-model="bold"> Bold <br>
          <input type="checkbox" ng-model="red"> RED Color
          <hr>
      </div>
     </div>
   </div>
   <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.9/angular.min.js"></script>
   <script>
   var hello  = angular.module('helloApp',[]); 
   hello.controller('HelloController'function($scope){
   });
   </script>
  </body>
</html>
cs

댓글 없음:

댓글 쓰기