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

android - questions about switching from C2DM to GCM -

c++ - Qt setGeometry: Unable to set geometry -

batch file - How to extract all multi-volume RAR archives from subfolders of a folder? -