formations/javascript/angular/directives-4.md

578 B

.cadoles-slide-title[Les directives de base (4/5)]

Modification dynamique du style: ng-class

<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>