Controller:$scope.dataList=[
{"dataClass":"0","dataName":"A1"},
{"dataClass":"0","dataName":"A2"},
{"dataClass":"1","dataName":"B1"},
{"dataClass":"1","dataName":"B2"},
{"dataClass":"2","dataName":"C1"},
{"dataClass":"2","dataName":"C2"}
]
HTML template:
<li ng-repeat="item in dataList |filter :{'dataClass':'0'}">{{item.dataName}}</li>
The page display will loop to filter out A1 and A2 whose dataClass is '0' in the dataList array; current requirements The value filtered by dataClass is a variable set to variability, and ng-repeat="item in dataList |filter :{'dataClass':varity}", and it does not take effect. How can I achieve this requirement
I wrote a filter for you and removed the specified dataClass:
The filter receives 3 parameters, the original array, the key to be filtered, and the specified key value.
Just add curly brackets