HTML page:
1 <Table>2 <thead>3 <TR>4 <TDclass= "TD">Serial number</TD>5 <TDclass= "TD">Planning uses</TD>6 </TR>7 </thead>8 <tbody>9 <TRng-repeat= "FW in Fwlist">Ten <TDclass= "TD"Ng-bind= "$index +1">1</TD> One <TDclass= "TD">{{FW. Ghyt|name}}</TD> A </TR> - </tbody> - </Table>
Filter:
1define ([' angular '),function(ng) {2' Use strict ';3Ng.module (' Index-filters ', [])4 5. Filter (' Price ', [function () {6 7 return function(num) {8 9 return' ¥ ' +num;Ten One }; A - }]) -. Filter (' Gender ', [function () { the - return function(gender) { - - Switch(gender) { + - Case1:returnMale; + A Case2:returnFemale; at - Case0:return‘‘; - - } - - } in - }]) to. Filter (' NAME ', [function () { + - return function(YWLX) { the * if(YWLX = =NULL)return""; $ Panax Notoginseng - varstr =YWLX; the + if(Ywlx.length > 10) { A thestr = ywlx.substring (0, 10) + "..."; + - } $ returnstr; $ - } - the }]) -. Filter (' Stateimgurl ', [function () {Wuyi the return function(state) { - Wu Switch(state) { - About Case' Normal ':return‘.. /img/normal.png '; $ - Case' Warning ':return‘.. /img/warning. PNG '; - - Case' Overdue ':return‘.. /img/timeout.png '; A } + the } - $ }]) the. Filter (' Ghyttoname ', [' Audit-service ',function(auditservice) { the //Audit-service Service the varTempData = []; theAuditservice.getparameter ("Housing use"). Success (function(sjlxlist) { - inTempData =sjlxlist; the the }); About the return function(ID) { the for(vari = 0; i < tempdata.length; i++) { the + if(Tempdata[i]. Code = =ID) { - the returnTempdata[i]. Name;Bayi } the } the } - }]) -})
The required controller for the HTML page:
1 function (APP) {2 app.controller (' Index-controller ', [' $rootScope ', ' $scope ', ' $location ', ' $cookies ') , 3 function ($rootScope, $scope, $location, $cookies) {45 }]) 6 })
Angularjs Summary (ii) filter use