how to filter selected array values with compare two fields . here i have selected samsung with some services(Regular Service, Settings Faults) and redirecting to listing page .lisitng page i am getting filter value like this samsung ,Regular Service, Settings Faults here i want to compare with S_Store,S_Services. i have checked only $_store its working but Regular Service, Settings Faults i need to check with S_Services. how can i do some one help me out.
.controller('SamsungServicesCtrl', function ($scope,$filter,$location) {
var service = ["Regular Service", "Settings Faults", "Software Faults", "Hardware Faults"];
var services = ["General services", "If a phone doesn’t switch-on, it is called a dead phone, SIM card does not get detected", "Hardware Faults"];
var icons = ["images/arrow.svg","images/arrow.svg","images/arrow.svg"];
$scope.items= [] ;
for(var i=0;i<service.length;i++)
{
var modal = {
name:service[i],
subname:services[i],
icon:icons[i],
selected:false
};
$scope.items.push(modal);
}
scope.check = function()
{
var checkedItems = [];
for(var i=0;i<$scope.items.length;i++){
if($scope.items[i].selected){
checkedItems.push($scope.items[i].name);
}
}
//$location.path('menulisting/listing');
var model ="samsung";
//i have checked Regular Service, Settings Faults
$location.path('menulisting/listing').search({filter: model +','+checkedItems});
}
})
listing controller
.controller('ListingCtrl', [
'$scope', '$http', '$location', '$window', '$filter','$ionicPopover','$ionicLoading',
function($scope, $http, $location, $window, $filter, $ionicPopover, $ionicLoading) {
$http.get('****').success(function(data,dealers,response)
{
var filter= $location.search().filter;
console i am getting
//samsung,Regular Service, Settings Faults
$scope.dealers=[];
for(var i=0;i<data.length;i++){
var temp=data[i].S_Store.split(',');
for(var j=0;j<temp.length:j++){
if(temp[j]===filter)
$scope.dealers.push(data[i]);
console.log($scope.dealers);
}
}
});
}])
$scope.dealers i am getting in console like this
console i am getting like this
1: Object
$$hashKey: "object:28"
Dealer_id: "55b24172c7d354f30cda0e7f"
Legal_Name: "Adtiya Samsung Store"
S_Address: Object
address_line1: "No.80, Marks Road"
area: "madiwala"
city: "Bangalore"
state: "Karnataka"
zipcode: "560068"
S_Date_add: "2015-07-24T13:45:23.927Z"
S_Email_id: "aditiya@gmail.com"
S_Store: "samsung"
Store_Name: "Adtiya Samsung Store"
S_Services:"Regular Service,Settings Faults,Software Faults,Hardware Faults"
Store_long_description: "Undertake all kind of samsung mobiles"
Store_short_description: "Undertake all kind of samsung mobiles"
2: Object
$$hashKey: "object:28"
Dealer_id: "55b24172c7d354f30cda0e7g"
Legal_Name: "sri shakthi mobile services"
S_Address: Object
address_line1: "3rd street"
area: "madiwala"
city: "Bangalore"
state: "Karnataka"
zipcode: "560068"
S_Date_add: "2015-07-24T13:45:23.927Z"
S_Email_id: "rajs@gmail.com"
S_Store: "nokia"
Store_Name: "sri shakthi mobile service"
S_Services:"Regular Service,Settings Faults,Software Faults,Hardware Faults"
Store_long_description: "Undertake all kind of nokia mobiles"
Store_short_description: "Undertake all kind of nokia mobiles"
3: Object
$$hashKey: "object:28"
Dealer_id: "55b24172c7d354f30cda0e7h"
Legal_Name: "sun mobile service center"
S_Address: Object
address_line1: "23rd main ,2nd cross"
area: "madiwala"
city: "Bangalore"
state: "Karnataka"
zipcode: "560068"
S_Date_add: "2015-07-24T13:45:23.927Z"
S_Email_id: "sprtive23@gmail.com"
S_Store: "nokia,samsung"
Store_Name: "sun mobile service center"
S_Services:"Regular Service,Settings Faults,Software Faults,Hardware Faults"
Store_long_description: "Undertake all kind of nokia,samsung mobiles"
Store_short_description: "Undertake all kind of nokia,samsung mobiles"
home page
<div ng-controller="SamsungServicesCtrl">
<ion-content>
<li class="item item-checkbox" ng-repeat="item in items" >
<img src="{{item.icon}}" style="float:left;height:30px;width:30px;padding-right:5px;" >
<label class="checkbox checkbox-energized" >
<input type="checkbox" style="float:right;" ng-model="item.selected" >
</label>
{{item.name}}
<p style="font-size:10px; padding-left:0px;"> {{item.subname}}</p>
</li>
<div class="padding">
<button class="button button-full button-energized" value="submit" ng-click="check()">Apply
</button>
</div>
</ion-content>
</div>
listing page
<div class="bar bar-header item-input-inset">
<label class="item-input-wrapper" >
<i class="icon ion-ios-search placeholder-icon"></i>
<input type="text" placeholder="Search" ng-model="query" >
</label>
</div>
<div class="list card" data-ng-repeat="dealer in dealers | filter:query ">
<div class="item item-thumbnail-left item-icon-right" href="#">
<h2>{{dealer.Store_Name}}</h2>
<p>{{dealer.S_Address.area}} {{dealer.S_Address.city}}</p>
<p>{{dealer.S_Services}}</p>
</div>
</div>