Click to change style

Description

The following code shows how to click to change style.

Example


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<style type='text/css'>
.red {<!--from w w w  . j  a va 2s  . c o m-->
    color: red;
}
.blue {
    color: blue;
}
</style>
</head>
<body>
  <div ng-app>
    <button ng-class="myClass" 
            ng-click="myClass='red'" 
            ng-init="myClass='blue'">some text</button>
</div>
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities