我看到的过滤器很少
<tr ng-repeat="x in list | filter:search| offset:currentPage*pageSize| limitTo:pageSize ">
Run Code Online (Sandbox Code Playgroud)
在我的项目中取得好成绩,我必须在控制器中进行这种过滤而不是在视野中
我知道基本语法 $filter('filter')('x','x')但我不知道如何在控制器中创建过滤器链,所以一切都将像我的模板中的示例一样工作.
我找到了一些解决方案,现在只使用一个过滤器,但应该可以使用很多;)
$scope.data = data; //my geojson from factory//
$scope.geojson = {}; //i have to make empty object to extend it scope later with data, it is solution i found for leaflet //
$scope.geojson.data = [];
$scope.FilteredGeojson = function() {
var result = $scope.data;
if ($scope.data) {
result = $filter('limitTo')(result,10);
$scope.geojson.data = result;
console.log('success');
}
return result;
};
Run Code Online (Sandbox Code Playgroud)
我在ng-repeat工作中使用此功能很好,但我必须用几个过滤器检查它.
我试图为geojson创建一个模式,但是在坐标语法方面遇到了一些问题.
这是我目前的代码:
var DataSchema = new Schema({
properties: {
title: { type: String, required: true },
description: { type: String, required: true },
date: { type:Date, default:Date.now }
},
geometry: {
coordinates: []
}
});
Run Code Online (Sandbox Code Playgroud)
我尝试使用[](空数组),它创建''和[Number,Number],但它不工作.
我的问题是:我如何构建我的模式,以便得到结果
coordinates: [ 3.43434343, 5.543434343 ]
Run Code Online (Sandbox Code Playgroud)
没有引号,这可能吗?
快车道
app.post('/mountain_rescue', function (req, res){
new rescueData({properties:{title: req.body.title, description: req.body.description},geometry:{
coordinates:req.body.coordinates}}).save(function (e, result) {
console.log(result);
});
res.redirect('/mountain_rescue');
});
Run Code Online (Sandbox Code Playgroud)
视图
<div id="AddingPanel">
<form method="post" action="mountain_rescue" >
Title:<input type="text" name="title">
Description:<textarea …Run Code Online (Sandbox Code Playgroud) <input ng-model="search.name" placeholder="Name" />
<tbody>
<div ng-init="FilteredGeojson = ho|filter:search">
<tr ng-repeat="hf in FilteredGeojson">
<td>{{ hf.name }}</td>
</tr>
</div>
</tbody>
</table>
<div leaflet-directive id="map" data="FilteredGeojson"></div>
Run Code Online (Sandbox Code Playgroud)
如果可能的话,在ng-init中进行过滤是很重要的,但是我无法解决它,我无法进行ng-repeat和创建我传递给我的指令的范围,因为它启动了无限的摘要循环.
我想将google-maps与angular.js同步,因此我为google-maps创建了自定义指令.
码
var map;
map = new google.maps.Map(document.getElementById('map'),
mapOptions);
scope.$watch('geojson', function(newVal, oldVal) {
if (newVal !== oldVal) {
map.data.setMap(null);
map = new google.maps.Map(document.getElementById('map'),
mapOptions);
map.data.addGeoJson(scope.geojson);
}
}, true);
Run Code Online (Sandbox Code Playgroud)
我的解决方案有效,但它不是我想要实现的,当数据发生变化时,每次使用新的scope.geojson加载map,遗憾的是我找不到任何好的解决方案如何删除数据,我认为没有将geojson数据添加为图层的一些选项?然后在添加新的geojson之前清除此图层,这样map将是稳定的,只有geojson数据会改变?
1.Step
mainWindow = new BrowserWindow({
width: 1200,
height: 700,
center: true,
'min-height': 700,
'min-width': 1200,
webPreferences: {nodeIntegration:true}});
mainWindow.loadURL(HOME_URL);
Run Code Online (Sandbox Code Playgroud)
2.Step(某些事件发生,我想临时隐藏主窗口并显示另一个(createFacebookWindow()fn已经在loadingURL))
mainWindow.hide();
facebookWindow = require('./modules/auth/views.js').createFacebookWindow();
FB Window settings ({
width: 1200,
height: 700,
center: true,
'min-height': 700,
'min-width': 1200,
webPreferences: {nodeIntegration:false}})
Run Code Online (Sandbox Code Playgroud)
3.Step(另一个事件发生我破坏fb窗口并显示主窗口)
facebookWindow.close();
facebookWindow.on('closed', function() {
facebookWindow = null;
mainWindow.show();
//I tried below options it doesn't work
//mainWindow.setSize(1200, 700);
//mainWindow.setMinimumSize(1200, 700);
Run Code Online (Sandbox Code Playgroud)
摘要:
所以实际上在这些步骤之后,当我显示mainWindow时,它不记得mainWindow设置min-height和min-width不起作用.
当facebookWindow没有打开时,一切都很好,所以在用Windows切换时必须发生一些事情.也许某些事情的顺序错误?
angularjs ×3
javascript ×3
node.js ×2
electron ×1
express ×1
geojson ×1
google-maps ×1
mongodb ×1
mongoose ×1