我的代码中出现了一些问题,如果数据相同则隐藏数据。
此数据1. cars
形成JSON
[{ _id:1, id_ofcars:10},{ _id:2, id_ofcars:11},{ _id:3, id_ofcars:13},{ _id:4,
id_ofcars:14},{ _id:5, id_ofcars:15}]
和数据2.Owners
[{ _id:1, id_ownercars:10},{ _id:2, id_ownercars:11},{ _id:3, id_ownercars:13}]
我在controller
像这样创建
app.controller('appCtrl', ['$scope','$http', function ($scope,$http) {
function getCarsData() {
return $http.get('api/cars');
};
function getOwnersData() {
return $http.get('api/owners');
};
getCarsData().then(function(cek){
$scope.DataCARS = cek.data;
});
getOwnersData().then(function(cek){
$scope.DataOWNER = cek.data;
for (var i=0; i<$scope.DataOWNER.length; i++;){
$scope.REALOWNER = $scope.DataOWNER[i];
};
});
}]);
这是一个code html for options Data
<select class="form-control" name="level" id="level" ng-model="_id" ng-click="CheckSurvey(_id)" required>
<option value="">-- SELECT DATA --</options>
<option ng-repeat="data in DataCARS " ng-hide="data.id_ofcars ===
REALOWNER.id_ownercars" value="{{data._id}}">{{data.nama}}</option>
</select>
为什么在loop
之后我将$scope.REALOWNER.id_ownercars
放入ng-hide
,为什么他不隐藏id_ofcars
?我只想隐藏数据?
答案 0 :(得分:1)
1.-做什么Aleksey说(这更好)
2.-使用顺序搜索
例:
https://github.com/CayetanoHerreraLuisRicardo/sequential-Search/blob/master/sequentialSearch.js