0
我想用angularjs過濾器。如何在設施中找到阿門。 amen = 1; amenities =「1,3,7,9,12」;Angularjs過濾器在文本中搜索
這是我的代碼:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.min.js"></script>
<input type="checkbox" name="more_filter[]" value="1" class="pull-left amenities" id="amen-1" ng-checked="false">
amenities = "1, 3, 7, 9, 12";
//amen 1
$("#amen-1").on("click", function() {
var amen = document.getElementById("amen-1").val();
$scope.amen = amen;
$scope.$apply();
$scope.ot_Filter = function (location) {
return location.amenities == $scope.amen;
};
});
我想搜索的設施阿門。我如何在這條線的變化:
location.amenities == $scope.amen
謝謝你..
編輯: 問題的解決@貢薩洛的幫助:
<input type="checkbox" name="more_filter[]" value="1" class="pull-left amenities" ng-click="am_1();" id="map-search-amenities-1">
$scope.am_1 = function()
{
var kontrol = document.getElementById("map-search-amenities-1").checked;
if (kontrol==true) {
$scope.ot_Filter = function (location) {
return location.amenities.indexOf(1)==0;
};
} else {
$scope.ot_Filter = function (location) {
return location.amenities;
};
}
}
我想我需要看到更完整的代碼才能正確地幫助您使用此示例 –
「amenities」不是數組嗎? – deividfortuna
不,它不是數組 – toplumdusmani