任何人都可以告诉如何在所有属性中搜索字符串。如果在某些属性中匹配,我需要在AngularJS中推送数组中的对象。
我有一个数组
$scope.ListOfPeople = [
{ PersonID: 10, FirstName: "John", LastName: "Smith", Sex: "Male" },
{ PersonID: 11, FirstName: "James", LastName: "Last", Sex: "Male" },
{ PersonID: 12, FirstName: "Mary", LastName: "Heart", Sex: "Female" },
{ PersonID: 13, FirstName: "Sandra", LastName: "Goldsmith", Sex: "Female" },
{ PersonID: 14, FirstName: "Shaun", LastName: "Sheep", Sex: "Male" },
{ PersonID: 15, FirstName: "Nicola", LastName: "Smith", Sex: "Male" }
];
如果用户在搜索文本框中键入了一些值。我需要使用PersonID,FirstName,LastName,Sex搜索所有属性,如果匹配需要推送匹配的对象。
答案 0 :(得分:2)
我认为Angular的Filter过滤器可以满足您的需求
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit fromDate:[NSDate date]];
NSInteger currentHour = [components hour];
答案 1 :(得分:0)
那样的东西?
for(var index in $scope.ListOfPeople) {
if ($scope.ListOfPeople.hasOwnProperty(index)) {
if($scope.ListOfPeople[index] == "Your string") {
// Do something here
}
}
}