Javascript AngularJS-使用Mysql进行过滤
我尝试根据邮政编码在静态(非谷歌)地图上设置标记。Javascript AngularJS-使用Mysql进行过滤,javascript,filter,resources,angularjs,Javascript,Filter,Resources,Angularjs,我尝试根据邮政编码在静态(非谷歌)地图上设置标记。 这是我的html代码: <div ng-controller="DealerMarkerListCtrl"> <a href="#/dealer/{{marker.id}}" class="marker" style="left:{{marker.left}}px;top:{{marker.top}}px" ng-repeat="marker in dealer|zipFilter:countryLookup">
这是我的html代码:
<div ng-controller="DealerMarkerListCtrl">
<a href="#/dealer/{{marker.id}}" class="marker" style="left:{{marker.left}}px;top:{{marker.top}}px" ng-repeat="marker in dealer|zipFilter:countryLookup"></a>
</div>
用于zipcode“45525”
现在我需要显示此Zipcode数组中的所有标记(经销商)。过滤器中的zip参数和国家参数需要发送到“区域搜索”功能“files/framework/umkreis/:zip/:country”,以获取该区域的zip json。
之后,我需要检查一些标记是否在这个json中,并对它们进行过滤 我只是不知道,如何把这些东西植入我的过滤器。你能帮我解决这个问题吗?多谢各位 其他有用信息:
路线和服务:
app.factory('dealerService', ['$resource', '$http', '$rootScope', function($resource, $http, $rootScope){
return {
//the resource provider interacting with the PHP backend
api:
$resource('files/framework/dealer/:id', {}, {
update: {method:'PUT'}
}),
}
}])
app.config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/dealer/:id', {templateUrl: 'files/tpl/dealer-details.html', controller: 'DealerDetailsCtrl'}).
otherwise({redirectTo: '/dealer'});
}]);
获取区域zipcodes的“Slim”框架路径为:
files/framework/umkreis/45525/DE
or
files/framework/umkreis/:zip/:country
看起来您正试图根据表单中的两个字段“zipCodeLookup”和“countryLookup”更新地图上的标记 您需要做的是在“DealerMarkerListCtrl”控制器中指定一个函数,该函数将获取一个邮政编码和一个国家/地区,并使用来自服务器的新JSON更新经销商
$scope.updateDealer = function(zip, country) {
$http.get('files/framework/umkreis/'+ zip + '/' + country).
success(function(data) {
$scope.dealer = data;
});
}
完成此操作后,您可以将ng submit
添加到包含将调用此函数的输入的
<form ng-submit="updateDealer(zipCodeLookup, countryLookup)"> ... </form>
。。。
确保
位于正确的控制器内,以查看新创建的功能。每当用户提交此表单时,它都会调用您的PHP服务器,获取JSON并更新经销商数组。我现在创建了一个自定义PHP函数,该函数的参数为userZip和country。它得到了给定拉链周围约20公里的区域。然后我检查经销商的zip是否在区域zip码数组中。输出(现在)是经过过滤的经销商Zipcode。方法如下:-如何使用此函数设置标记?我不能过滤,这是肯定的。。。正确的?
files/framework/umkreis/45525/DE
or
files/framework/umkreis/:zip/:country
<input ... ng-model="zipCodeLookup" ... />
<select ... ng-model="countryLookup" ... ></select>
<div ng-controller="DealerMarkerListCtrl"></div>
files/framework/umkreis/:zip/:country
$scope.updateDealer = function(zip, country) {
$http.get('files/framework/umkreis/'+ zip + '/' + country).
success(function(data) {
$scope.dealer = data;
});
}
<form ng-submit="updateDealer(zipCodeLookup, countryLookup)"> ... </form>