formations/javascript/angular/directives-4.md
2015-04-09 20:36:17 +02:00

24 lines
578 B
Markdown

# .cadoles-slide-title[Les directives de base (4/5)]
**Modification dynamique du style: `ng-class`**
```html
<html>
<body ng-app="myApp">
<style>
.red { color: red; }
.blue { color: blue; }
.xxl { font-size: 50px; font-weight: bold; }
</style>
<div ng-controller="MainCtrl" ng-init="iLoveBlue=true; iLoveRed=false; myClasses=['red', 'xxl']">
<span ng-class="myClasses">Rouge et large</span>
<span ng-class="{'red': iLoveRed, 'blue': iLoveBlue}">Bleu</span>
</div>
<script src="angular.js"></script>
</body>
</html>
```