Ng Ng Style
# AngularJS `ng-style` Directive
[ AngularJS Reference](#)
* * *
## AngularJS Example
Use AngularJS to add styles, using CSS key=>value object format:
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.myObj = {
"color" : "white",
"background-color" : "coral",
"font-size" : "60px",
"padding" : "50px"
}
});
[Try it Β»](#)
* * *
## Definition and Usage
**ng-style** directive adds style attributes to HTML elements.
**ng-style** attribute value must be an object, and the expression returns an object as well.
The object consists of CSS properties and values, i.e., key=>value pairs.
* * *
## Syntax
All HTML elements support this attribute.
* * *
## Parameter Values
| Value | Description |
| --- | --- |
| _string_ | Expression returns an object composed of CSS properties and values. |
* * AngularJS Reference](#)
[](#)(#)
(#)[](#)
[ByteArk Coding Plan supports mainstream large models including Doubao, GLM, DeepSeek, Kimi, MiniMax, etc., with official direct supply for stability and reliability. Configuration Guide Β₯9.9/month Activate Now](https://maas.xfyun.cn/modelSquare?ch=maas_lm_l2E)
YouTip