js:
$scope.arr = [
["212","上","下","左","右"],
["12","1","2","3","4"],
]
html:
<input type="text" ng-model="text">
<tr ng-repeat="dataTr in arr | filter:text">
<td ng-repeat="dataTd in dataTr">
<ng-switch on="$first">
<span ng-switch-when="true">{{index+1}}</span>
<span ng-switch-default>{{dataTd}}</span>
</ng-switch>
</td>
</tr>
The first column in the two-dimensional array is not displayed, so you need to exclude arri when searching. If I enter 1, both columns are included, but if I enter 1, only arr[0] will be displayed. How to do this? I wrote filter as a function, but I didn’t get it done
Use arr.slice(1, arr.length)
Okay, I read the question wrong, just add a map
Since angular expression does not support function declaration, you need to write this paragraph in the controller and reassign it to
$scope.arr