Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

highlight first,middle,last with ng-class

<!doctype html>
<html>
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.6/angular.js"></script>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
    
    <script>
        var app = angular.module('testApp', []);
        app.controller('CtrlOne', ['$scope', function($scope){
            $scope.students = ["Tanveer","Ehtesham","Rizwan","Salman","Atif","Kashif"];
            $scope.dynamicClasses = "{ 'first': $first, 'middle': $middle, 'last': $last, 'odd':$odd, 'even':$even}";
        }])

    </script>
    <style>
        .first{
            color:green;
        }
        .middle{
            color:grey;
        }
        .last{
            color:red;
        }
    </style>
  </head>
  <body ng-app="testApp">
    <div ng-controller="CtrlOne">
        <p ng-repeat="student in students" ng-class="{{dynamicClasses}}">{{student}}</p>
    </div>
    
  </body>
</html>

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.