javascript - How do I pass a angularjs variable into html tag? -


in controller:

$scope.height = "height:100px;"; $scope.color = "red" 

in html:

<div class="capsule" ng-style="{'height': height; 'background': color}"></div> 

how can make work?

you have semi colon ';' in between style, ng-style expects object (comma separated). below code should work -

<div class="capsule" ng-style="{'height': height, 'background': color}"></div> 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -