Thursday, September 11, 2014

AngularJS binding inside of style tag

Now supported in v1.3+

See plunkr = http://plnkr.co/edit/utsD4RimPB6RSKXnAlLi?p=preview
 <!DOCTYPE html>  
 <html ng-app>  
  <head>  
   <link rel="stylesheet" href="style.css">  
   <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-rc.0/angular.js"></script>  
   <style>  
    .mydiv {  
     height: {{height}}px;  
     width: {{width}}px;  
     background-color: red;  
    }  
   </style>  
  </head>  
  <body style="width:100%;height:100%;">  
   <div class="mydiv" ng-init="height= 100; width=200"></div>  
   h: {{height}} w: {{width}}  
  </body>  
 </html>