Monday, November 23, 2015

Angular- Filters

 Name:<input type ="text" ng-model="Name"/><br><br>

//Formats a number as a currency
 <span>subtraction :{{num1-num2|currency}}</span><br><br>

//Converts the specified string to uppercase
    <span>subtraction :{{Name|uppercase}}</span><br><br>




number

Formats a number as text.

 <h1>Hello Plunker!</h1>
    number :<input type ="text" ng-model='val'><br>
    Default formatting: <span id='number-default'>{{val | number}}</span><br>
    No fractions: <span>{{val | number:0}}</span><br>
    Negative number: <span>{{-val | number:4}}</span>

orderBy


it is ordered alphabetically for strings and numerically for numbers.
<!DOCTYPE html>
<html ng-app="myapp">

  <head>
    <link rel="stylesheet" href="style.css">
    <script src="script.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0-beta.2/angular.min.js"></script>
  </head>

  <body>
   <div ng-controller='ageController'>
     <table border=1>
       <tr>
         <td>name</td>
         <td>age</td>
         
       </tr>
       <tr ng-repeat="p in person|orderBy:'age'">
         <td>{{p.name}}</td>
         <td>{{p.age}}</td>  
       </tr>
       </table>
   </div>
    
    <script>
      angular.module('myapp', [])
      .controller('ageController',function($scope)
      {
        $scope.person=[{"name":"tom", age:30},{"name":"harry", age:25}]
      });
    </script>
  </body>

</html>



No comments:

Post a Comment