1

在這段代碼中我沒有得到客戶的未排序列表,也沒有城市名在這段代碼中,我沒有獲取客戶名單和城市名稱。爲什麼?

<!DOCTYPE html> 

    <html data-ng-app=""> 

    <head> 
     <title>Using AngularJS Directives and Data Binding </title> 
    </head> 

    <body data-ng-init="customers=[{name:'Rishabh Shrivas',city:'New Delhi'},{name:'Rishabh Bharadawaj',city:'Noida'},{name:'Rishabh Sen ,city:'Gurgaon'}] "> 
     Name : 
     <br /> 
     <input type="text" data-ng-model="name" placeholder="Enter Your Name " /> {{ name }} 
     <br /> 

     <ul> 
      <li data-ng-repeat="cust in customers | filter:{name} "> {{ cust.name }} - {{ cust.city }} </li> 
     </ul> 


     <script src="Scripts/angular.min.js"></script> 

    </body> 


    </html> 

回答

0

你在NG-INIT失蹤'和不使用{}過濾器。

<body data-ng-init="customers=[{name:'Rishabh Shrivas',city:'New Delhi'},{name:'Rishabh Bharadawaj',city:'Noida'},{name:'Rishabh Sen' ,city:'Gurgaon'}]"> 
     Name : 
     <br /> 
     <input type="text" data-ng-model="name" placeholder="Enter Your Name " /> {{ name }} 
     <br /> 

     <ul> 
      <li data-ng-repeat="cust in customers | filter:name "> {{ cust.name }} - {{ cust.city }} </li> 
     </ul> 
</body> 
+0

我使用納克-INIT <體數據-NG-INIT = – fool

+0

這很好,但看到這個{名稱:'裏沙布森,城市:'古爾岡'}。森後,你失去了一個接近完成它 –

+0

瞭解它.thk你 – fool

0

檢查這一個

你的過濾器應該是這樣的

data-ng-repeat="cust in customers | filter:name " 

更新的HTML:

<body data-ng-init="customers=[{name:'Rishabh Shrivas',city:'New Delhi'},{name:'Rishabh Bharadawaj',city:'Noida'},{name:'Rishabh Sen' ,city:'Gurgaon'}] "> 
     Name : 
     <br /> 
     <input type="text" data-ng-model="name" placeholder="Enter Your Name " /> {{ name }} 
     <br /> 

     <ul> 
      <li data-ng-repeat="cust in customers | filter:name "> {{ cust.name }} - {{ cust.city }} </li> 
     </ul> 




    </body> 
相關問題