Angularjs Examples

AJS Examples

AngularJS ng-class Directive

The AngularJS ng-class directive is used to set css class dynamically.


<p ng-class="{margin:1px;font-family:Cambria;font-size:20px;}">Class Example</p>

AngularJS ng-class Directive Example

<title>My first AngularJS ng-class Directive code</title>
<Script SRC="">
//Defining Controller Using Standard Javascrip Object Constructor
function CustomerController($scope) {
$scope.siteName = "";
$scope.clicked = function()
		$scope.siteCSS = "{font-family:Cambria;font-size:20px;}";
<div ng-app="">
<div ng-controller="CustomerController"> 

<input id="btnButton" type="button" value="Change Font" ng-change="clicked">
{{ siteName }}
See Live Example