2016-03-03 31 views
0

我有一個用戶名和密碼登錄畫面,我以服務保存用戶名變量。(讓它成爲getservice.usrname)使用用戶名從數據中排序?

我有數據列表,即時通訊使用的打印在下一頁的整個數據NG-重複。我想要的是打印特定人員的詳細信息,即使用用戶名過濾。

[{ 
"username": "vishnu", 
"FromDate": "Wed Mar 02 2016 10:56:45 GMT+0530 (India Standard Time)", 
"selectedProject": "createwhimsy", 
"task": "fixing bugs", 
"time": "1" 
}, { 
"username": "seenu", 
"FromDate": "Wed Mar 02 2016 10:56:45 GMT+0530 (India Standard Time)", 
"selectedProject": "createwhimsy", 
"task": "working on ui", 
"time": "2" 
    }, { 
"username": "sam", 
"FromDate": "Wed Mar 02 2016 10:56:45 GMT+0530 (India Standard Time)", 
"selectedProject": "bigiron", 
"task": "working on api", 
"time": "5" 
    }, 
    { 
"username": "vishnu", 
"FromDate": "Wed Mar 03 2016 10:56:45 GMT+0530 (India Standard Time)", 
"selectedProject": "timetracker", 
"task": "ui designing", 
"time": "1" 
}] 
+0

它的工作,但簡單的方法有....看到答案...由阿比德 –

回答

0

這是angularJS簡單,這裏是示例代碼,

在控制器,

$scope.list= [{ 
    "username": "vishnu", 
    "FromDate": "Wed Mar 02 2016 10:56:45 GMT+0530 (India Standard Time)", 
    "selectedProject": "createwhimsy", 
    "task": "fixing bugs", 
    "time": "1" 
    }, { 
    "username": "seenu", 
    "FromDate": "Wed Mar 02 2016 10:56:45 GMT+0530 (India Standard Time)", 
    "selectedProject": "createwhimsy", 
    "task": "working on ui", 
    "time": "2" 
     }, { 
    "username": "sam", 
    "FromDate": "Wed Mar 02 2016 10:56:45 GMT+0530 (India Standard Time)", 
    "selectedProject": "bigiron", 
    "task": "working on api", 
    "time": "5" 
     }, 
     { 
    "username": "vishnu", 
    "FromDate": "Wed Mar 03 2016 10:56:45 GMT+0530 (India Standard Time)", 
    "selectedProject": "timetracker", 
    "task": "ui designing", 
    "time": "1" 
    }] 

和在HTML文件,

<ul> 
    <li ng-repeat="u in list| filter:{username:'vishnu'}"> 
     // print your items 
    </li> 
</ul> 

這裏是plnkr的例子。 http://plnkr.co/edit/gtfikICLQFeGgrgV7I0i?p=preview

0

一個經典的角度溶液,是使用filter

財產以後那樣:

<input type="text" class="form-control" ng-model="query"> 
<div ng-repeat="user in ctrl.data | filter:query"> 
<ul> 
     <li>{{user.username}}</li> 
     <li>{{user.task}}</li> 
    </ul> 
</div> 

見:https://jsfiddle.net/ronapelbaum/7a7f48o3/