Ng-Style-1

 

In this on button click we can set the style and style will assign to the ng-style directive which will implemented on text.

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app> <div> <button ng-click="style={color:'Red'}">Set Color</button> <button ng-click="style={backgroundColor:'yellow'}">Set Background Color</button> <button ng-click="style={}">reset</button><br /> <span ng-style="style">Sample text</span> </div> </body> </html>
Output