The ng-style syntax is not quite like that. It accepts a dictionary of keys (attribute names) and values (the value that they should take, an empty string disables them), and not just a string. I think you want this:
<div ng-style="{ 'width' : width, 'background' : bgColor }"></div>
And then in your controller:
$scope.width = '900px'; $scope.bgColor = 'red';
This preserves the separation of the template and the controller: the controller stores semantic values, and the template matches them with the correct attribute name.
musically_ut Nov 29 '13 at 13:50 2013-11-29 13:50
source share