我做錯了什麼,因爲我無法實現我需要的結果。在單獨的過濾器中有多個複選框的角度過濾器
我的JSON數據看起來像這樣
[{
type_id: 1,
brand_id: 0,
name: 'Title',
description: 'Description',
img: 'url'
},...]
所以我需要通過type_id
和brand_id
過濾數據它不是一個複雜的任務,但卡住了很多,我會很高興從你我任何幫助目前無法處理。
這就是我的觀點。我有兩個過濾器,它們是由ng-repeat 和ng-repeat生成的,用於我需要按類型和品牌過濾器進行過濾的設備。
// filter 1
<div class="filters">
<h3 class="filters__title">Choose by type</h3>
<div class="swiper-container">
<div class="swiper-arrow-prev"></div>
<div class="swiper-arrow-next"></div>
<div class="swiper-overflow">
<div class="swiper-wrapper filter" data-id="type">
<div class="swiper-slide filter__checkbox" ng-repeat="item in types">
<input type="checkbox" name="{{item.id}}" id="filter-{{item.id}}" ng-model="item.id" ng-checked="item.id">
<label for="filter-{{item.id}}">
<span>{{item.type}}</span>
</label>
</div>
<!-- /item -->
</div>
<!-- /filter -->
</div>
</div>
</div>
<!-- /filters -->
// filter 2
<div class="filters">
<h3 class="filters__title">Choose by brand</h3>
<div class="swiper-container">
<div class="swiper-arrow-prev"></div>
<div class="swiper-arrow-next"></div>
<div class="swiper-overflow">
<div class="swiper-wrapper filter" data-id="brands">
<div class="swiper-slide filter__checkbox" ng-repeat="brand in brands">
<input type="checkbox" name="{{brand.id}}" id="brand-{{brand.id}}" ng-model="brand.id">
<label for="brand-{{brand.id}}">
<img ng-src="{{brand.img}}" alt="">
<span>{{brand.name}}</span>
</label>
</div>
<!-- /item -->
</div>
<!-- /filter -->
</div>
<!-- /swiper-overflow -->
</div>
<!-- /swiper-container -->
</div>
<!-- /filters -->
<div class="card" ng-repeat="device in devices">
<div class="card__wrap">
<figure>
<img ng-src="{{device.img}}" alt="">
</figure>
<!-- /img -->
<h3 class="card__title">{{device.model}}</h3>
</div>
</div>
<!-- /card -->
angular.module('app', []).controller('mainCtrl', ['$scope', 'dataJSON', '_', function($scope, dataJSON, _) {
$scope.filterContainer = [];
// get Data
dataJSON.getPromise().then(function(data) {
$scope.brands = data.brands;
$scope.devices = data.devices;
$scope.types = data.device_types;
return data.devices;
}).then(function(data) {
})
}])
不知道這個問題的答案是令人信服我學習角的js –
沒有得到什麼你究竟在尋找.. –