JS Object All Properties Goto map

Source: Internet
Author: User

1<! DOCTYPE html>234<meta charset= "UTF-8" >5<title>angular Basics-Custom Filters </title>67<body>8<div ng-app= "MYAPP" >9<div ng-controller= "Myctrl" >Ten One<table border= "1" width= ">" A<th> -<td> name </td> -<td> Age </td> the<td> Height </td> -</th> -&LT;TR ng-repeat= "Item in Items" > -<td>{{$index +1}}</td> +<td>{{item.name}}</td> -<td>{{item.age}}</td> +<td>{{item.stature}}</td> A</tr> at<tr> -<td> Total </td> -<td></td> -&LT;TD ng-bind= "items | Sumage:items: ' Age ' ></td> -<td></td> -</tr> in</table> -</div> to  +</div> -<script src= "Http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js" ></script> the<script type= "Application/javascript" > *     varMyApp = Angular.module (' MyApp ', [' Myapp.filter ']); $     varAppfilter = Angular.module (' Myapp.filter '), []);Panax Notoginseng     //Custom Filters -Myapp.filter (' Sumage ',function () { the         //The second argument is summed according to the first argument +         return function(Input, N1, N2) { A             //console.log ("Input value:" +input); theConsole.log ("First parameter:" +N1); +Console.log ("second parameter:" +n2); -             varsum = 0; $Allprpos (n1[0]); $  -             /*For (var int = 0; int < input.length; int++) { - sum + = parsefloat (input[int].n2); the              };*/ -             returnsum;Wuyi         } the     }); -     functionAllprpos (obj) { Wu         //a map to hold all the property names and values -         varPropsmap =NewMap (); About         //Start Traversal $          for(varPinchobj) {//property is Method -             if(typeof(obj [p]) = = "function") { - obj [P] (); -}Else{//p is the property name, Obj[p] is the value of the corresponding property A propsmap.put (p,obj[p]); +             } the         } -         //Show all properties at the end $ Console.log (propsmap); the     } the  the     //a function that encapsulates an HTTP request key-value pair the     functionMap () { -          This. Keys =NewArray (); in          This. data = {}; the         //to add a key-value pair the          This. put =function(key, value) { About             if( This. data[key] = =NULL) {//Add a key name to the key field array if the key does not exist the                  This. Keys.push (key); the             } the              This. data[key] = value;//Assigning a value to a range of values for a key index +         }; -         //gets the value corresponding to the key the          This. get =function(key) {Bayi             return  This. Data[key]; the         }; the         //Remove key values (remove key names from key data and corresponding values) -          This. remove =function(key) { -              This. Keys.remove (key); the              This. Data[key] =NULL; the         }; the         //determines whether the key value element is empty the          This. IsEmpty =function() { -             return  This. Keys.length = = 0; the         }; the         //get key value element size the          This. Size =function() {94             return  This. keys.length; the         }; the     } the 98</script> About<script> -Myapp.controller (' Myctrl ', [' $scope ',function($scope) {101$scope. Items = [102             {103Name: ' Lu Xun ',104Age:27, thestature:165106             },107             {108Name: ' Hu Shi ',109Age:25, thestature:170111             }, the             {113Name: ' Chekhov ', theAge:27, thestature:175 the             },117             {118Name: ' Balzac ',119Age:29, -stature:165121             }];122     }]);123</script>124</body> the

JS Object All Properties Goto map

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.