Latest web development tutorials

AngularJS ng-style command

AngularJS Reference Manual AngularJS Reference Manual


AngularJS examples

Use AngularJS add style using CSS key => value object format:

<Body ng-app = "myApp " ng-controller = "myCtrl">

<H1 ng-style = "myObj "> tutorial </ h1>

<Script>
var app = angular.module ( "myApp", []);
app.controller ( "myCtrl", function ($ scope) {
$ Scope.myObj = {
"Color": "white",
"Background-color": "coral",
"Font-size": "60px",
"Padding": "50px"
}
});
</ Script>
</ Body>

try it"

Definition and Usage

ng-style instruction for the HTML elements to add style attributes.

ng-style attribute value must be an object, the object is returned by the expression.

Object registration by the CSS properties and values ​​that the key => value pairs.


grammar

<Element ng-style = "expression "> </ element>

All HTML elements support this property.


Parameter Value

value description
string An expression that returns an object by the CSS properties and values ​​thereof.

AngularJS Reference Manual AngularJS Reference Manual