Issue with angularjs filter sample -


i trying learn angularjs of book. tried execute 1 of examples on how use filters in angularjs not giving desired results. not sure missing , wrong code.

below code:

 <!doctype html>     <html>     <head>     <title> listing 4-4</title>     <script src="js/angular.min.js"></script>     <script>         function myfilterdemo($scope){             var somedata = {                     name: 'ashwini',                     address: 'noida',                     datejoined: new date(2015, 2, 14),                     consumption:4567.12358,                     plan: 'super basic plan'                 };                 $scope.data = somedata;             }      </script>     </head>     <body ng-controller ="myfilterdemo">         <p> consumption: {{data.consumption}}<br/>         <p> consumption: {{data.consumption | number}}     </body>  </html> 

if getting issue on filter , number filter used follows. {{ number_expression | number : fractionsize}}

there other problems in code.

check plnkr code working version.

<!doctype html> <html ng-app="myapp">    <head>     <meta charset="utf-8" />     <title>angularjs plunker</title>     <script>document.write('<base href="' + document.location + '" />');</script>     <link rel="stylesheet" href="style.css" />     <script data-require="angular.js@1.3.x" src="https://code.angularjs.org/1.3.15/angular.js" data-semver="1.3.15"></script>     <script>         var app = angular.module('myapp', []);         function myfilterdemo($scope){             var somedata = {                 name: 'ashwini',                 address: 'noida',                 datejoined: new date(2015, 2, 14),                 consumption:4567.12358,                 plan: 'super basic plan'                 };                 $scope.data = somedata;             }         app.controller("myfilterdemo",myfilterdemo)     </script>     </head>     <body ng-controller ="myfilterdemo">     <p> consumption: {{data.consumption}}<br/>     <p> consumption: {{data.consumption | number}}</p>    </body>    </html> 

http://plnkr.co/edit/tjpzoilwpga2dqiy5hpw?p=preview


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -