我是Angular的新手,所以我需要一些帮助才能推送markers.venues
中的项目。
我的代码是:
var app = angular.module("basicMapApp", ["leaflet-directive"]);
app.controller("CenterController",
[ '$scope', function($scope) {
angular.extend($scope, {
defaults: {
tileLayer: "https://dnv9my2eseobd.cloudfront.net/v3/foursquare.map-ikj05elx/{z}/{x}/{y}.png",
maxZoom: 14,
minZoom: 3,
},
center: {
lat: 52.38,
lng: 4.8777,
zoom: 6
},
markers: {
venues: {
Madrid: {
lat: 52.38,
lng: 4.8777,
message: "This is Madrid. But you can drag me to another position",
focus: false,
draggable: true
},
Barcelona: {
lat: 52.38,
lng: 5.8777,
message: "This is Barcelona. You can't drag me",
focus: false,
draggable: false
}
}
}
});
}]
);
如何在javascript中的markers.venues
中添加新项?
e.g。我尝试但没有工作:
$scope.markers.venues.push({
Amsterdam: {
lat: 52.38,
lng: 5.9777,
message: "This is Amsterdam. You can't drag me",
focus: false,
draggable: false
}
});
记录角度传单here
答案 0 :(得分:0)
试试这个
$scope..markers.venues['Amsterdam']={
lat: 52.38,
lng: 5.9777,
message: "This is Amsterdam. You can't drag me",
focus: false,
draggable: false
}