Tutorial 23 - AngularJS format and filtering?

AngularJS format and filtering

The sample show how to filter data in angularjs, filtering with currency format example.




 <!DOCTYPE html>  
 <html>  
 <script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>  
 <script>  
      angular.module('myWebApp', []).controller('listnamesCtrl',      function($scope) {   
      $scope.names = [   
      {name:'Lewis',country:'HoChiMinh'},   
      {name:'Kevin',country:'HaNoi'},   
      {name:'Vais',country:'DaNang'}   
      ];   
      });   
 </script>  
 <body>  
 <div ng-app="'myWebApp'" ng-controller="'listnamesCtrl'">  
 <p>Filtering input:</p>  
 <p><input type="text" ng-model="test"></p>  
 <ul>  
  <li ng-repeat="x in names | filter:test | orderBy:'country'">  
   {{ (x.name | uppercase) + ', ' + x.country }}  
  </li>  
 </ul>  
 </div>  
 </body>  
 </html>  

Filtering with currency format example.

 <!DOCTYPE html>  
 <html>  
 <script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>  
 <script>  
      angular.module('myWebApp', []).controller('listnamesCtrl',      function($scope) {  
 app.controller('fitercurrencyCtrl', function($scope) {  
   $scope.quantity = 1;  
   $scope.price = 9.99;  
 });  
 </script>  
 <body>  
 <div ng-app="'myWebApp'" ng-controller="'fitercurrencyCtrl'">  
 <input type="number" ng-model="quantity">  
 <input type="number" ng-model="price">  
 <p>Total = {{(quantity * price) | currency}}</p>  
 </div>  
 </body>  
 </html>  


18 comments:


  1. Thanks for sharing about Angular,It’s a structural framework for dynamic web application; it lets you extend the syntax of HTML to demonstrate your apps components clearly. All functionality happens inside the browser making it an ultimate companion with any server technology.
    Regards,
    Angularjs training in chennai

    ReplyDelete
  2. The oracle database is capable of storing the data in two forms such as logically in the form of table spaces and physically like data files.
    Oracle Training in Chennai | oracle dba training in chennai

    ReplyDelete
  3. This is Great and very useful advice with in this post. Thank you.
    webshere training in chennai

    ReplyDelete
  4. This blog was really amazing, thank you so much for sharing this blog.
    Motorcycle Tours in India

    ReplyDelete
  5. Pretty blog, so many ideas in a single site, thanks for the informative article, keep updating more article. Primavera Training in Chennai | Primavera online course

    ReplyDelete
  6. He's really nice and mean. it's a really cool blog. The link is a very useful thing. You have really helped a lot of people who visit the blog and give them useful information.

    Data Science Course in Durgapur

    ReplyDelete

Popular Posts