Ng-Style-2

 

In this example write the color name in the textbox and the entered color will assign to the ng-style directive and apply to the text displayed.

 
 
 
<!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> <style type="text/css"> .bg-color { background-color: orange; } </style> </head> <body ng-app="app"> <div ng-controller="controllerName"> <input type="text" ng-model="color" placeholder="Enter any color." /> <p ng-repeat="record in records" ng-style="{color:color}"> <span class="bg-color"> Name: {{record.name}}</span> </p> </div> <script> var app = angular.module("app", []); app.controller('controllerName', ['$scope', function ($scope) { $scope.records = [{ name: 'Java Script' }, { name: 'AngularJS' }, { name: 'Jquery' }, { name: 'Bootstrap' }]; }]); </script> </body> </html>
Output