我有一个工作选择选项,其中包含一些过滤数据以供搜索的值。
现在我需要几个链接作为侧边栏,这有助于直接单击并更改上面的选择选项
请参考我制作的这个链接网站链接。
登录示例:
用户:recobee@gmail.com
通行证:基肖尔
http://proconstruct.co.in/jsearch
Javascript:
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
var json = {
"modules":
<?php echo $qres; ?>
};
$scope.ocw = json;
var allCategories = json.modules.map(function(item) {
return item.designation
});
var filteredCategories = [];
var allCities = json.modules.map(function(item) {
return item.city
});
var filteredCities = [];
allCategories.forEach(function(item) {
if (filteredCategories.indexOf(item) < 0 && item) {
filteredCategories.push(item);
}
});
allCities.forEach(function(item) {
if (filteredCities.indexOf(item) < 0 && item) {
filteredCities.push(item);
}
});
$scope.search = {
designation: ""
}
$scope.search = {
city: ""
}
$scope.categories = filteredCategories;
$scope.updateFilter = function(value) {
$scope.search.designation = value;
}
$scope.cities = filteredCities;
$scope.updateFilter = function(value) {
$scope.search.city = value;
}
});
这些是链接 html :
<div ng-repeat="designation in categories ">
<a ng-click="updateFilter(search.designation)"> {{designation}}</a>
</div>
这是正在工作的选择,必须通过链接做出反应:
<select ng-model="search.designation">
<option value="">All Categories</option>
<option ng-repeat="category in categories" value="{{category}}">{{category}}</option>
</select>