2
我在我的角度項目中實現了智能表。目前,我有一些陣容中的人。智能表:通過列中的多個屬性進行搜索
$scope.persons = [
{
"firstname":"Anders",
"lastname":"Andersson",
"city":"Stockholm",
"country":"Sweden"
},
{
"firstname":"John",
"lastname":"Smith",
"city":"Washington DC",
"country":"USA"
}
];
我已綁定到我的表。
<table st-safe-src="persons" class="table">
<thead>
<tr>
<th><input st-search="firstname" class="form-control" type="search"/></th>
<th><input st-search="lastname" class="form-control" type="search"/></th>
<th><input st-search="city" class="form-control" type="search"/></th>
<th><input st-search="country" class="form-control" type="search"/></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="person in persons">
<td>{{person.firstname}}</td>
<td>{{person.lastname}}</td>
<td>{{person.city}}</td>
<td>{{person.country}}</td>
</tr>
</tbody>
</table>
這工作很順利。在每個列的每個頭中,我都可以搜索指定的屬性。但是,我想重做表格,並在同一列中包含兩個(或將來更多)屬性。在我相當簡單的例子中,我想將我的城市和鄉村房產加入下面指定的一列。
<table st-safe-src="persons" class="table">
<thead>
<tr>
<th><input st-search="firstname" class="form-control" type="search"/></th>
<th><input st-search="lastname" class="form-control" type="search"/></th>
<th><input st-search="???" class="form-control" type="search"/></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="person in persons">
<td>{{person.firstname}}</td>
<td>{{person.lastname}}</td>
<td>{{person.city}}, {{person.country}}</td>
</tr>
</tbody>
</table>
在這個變化中,我想在第三列中搜索城市和國家。我必須做些什麼才能實現該功能?