AngularJS ng-class Directive26 Sept 2024 | 1 min read The AngularJS ng-class directive facilitates you to dynamically set CSS classes on an HTML element by databinding an expression that represents all classes to be added. It may be a String, an object or an array. In case of a string, it should contain one or more, space-separated class names. In case of an object, it should contain key-value pairs, where the key is the class name of the class you want to add, and the value is a Boolean value. In the case of an array, it can be a combination of both. Note: The ng-class directive is supported by all HTML elements. Syntax: Parameter explanation: expression: It specifies an expression that returns one or more class names. Let's take an example to demonstrate ng-class directive. See this example: Test it NowNext TopicAngularJS ng-class-even Directive |
AngularJS ng-style Directive The AnglarJS ng-style directive facilitates you to set CSS style for the HTML elements. The value of ng-style attribute must be an object, or an expression returning an object. Object contains CSS properties and values, in key value pairs. It is supported by all HTML...
1 min read
AngularJS ng-selected Directive The AngularJS ng-selected directive adds the selected attribute on the element, if it gets that the expression inside ng-selected is true. The ng-selected directive is necessary to makes you able to shift the value between true and false. In HTML, the selected...
1 min read
AngularJS ng-class-odd Directive The AngularJS ng-class-odd directive works exactly same as ng-class, but it is used together with ng-repeat and take effect only on odd rows. The ng-class-odd directive is always used within the scope of ng-repeat directive. It is supported by all HTML elements. Syntax: <element ng-class-odd="expression"></element>...
1 min read
AngularJS ng-show Directive The AngularJS ng-show directive is used to show or hide the given HTML element according to the expression given to the ng-show attribute. It shows the specified HTML element if the given expression is true, otherwise it hides the HTML element. It is supported by all...
1 min read
AngularJS ng-bind-html Directive The AngularJS ng-bind-html directive is used to bind content to an HTML element securely. It evaluates the expressions and inserts the resulting HTML into the element in a secure way. By default, the resulting HTML content will be sanitized using the $sanitize service. You...
1 min read
AngularJS ng-csp Directive The AngularJS ng-csp directive is used to break certain CSP (Content Security Policy) rules. It changes the security policy of AngularJS. AngularJS containing ng-csp directive set will not run any eval functions, and it will not inject any inline styles. The following rules affect...
2 min read
AngularJS ng-click Directive The AngularJS ng-click directive facilitates you to specify custom behavior when an element is clicked. So, it is responsible for the result what you get after clicking. It is supported by all HTML elements. Syntax: <element ng-click="expression"></element> Parameter explanation: expression: It specifies an expression that is...
1 min read
AngularJS ng-init Directive The AngularJS ng-init directive facilitates you to evaluate the given expression in the current scope. Ng-controller is preferred over ng-init because the ng-init directive can add some unnecessary logic into the scope. It is supported by all HTML elements. Syntax: <element ng-init="expression" ></element> Parameter explanation: expression: It...
1 min read
AngularJS ng-checked Directive The AngularJS ng-checked directive is used to set a checked attribute on the element and add a checkbox or a radiobutton. You can set its value true or false. The checkbox, or radiobutton, will be checked if the expression inside the ng-checked attribute returns...
1 min read
AngularJS ng-switch Directive The AngularJS ng-switch directive facilitates you to hide/show HTML elements according to an expression. Child elements with the ng-switch-when directive will be displayed if it gets a match, otherwise the element, and its children will be removed. If you want to define a default section...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India