你需要纠正你的错误
Markers factory
factory
必须返回对象。
所以,改变一下:
myApp.factory("Markers", function(){
var Markers = [
{
"id": "0",
"coords": {
"latitude": "45.5200",
"longitude": "-122.6819"
},
"window": {
"title": "Portland, OR"
}
},
{
"id": "1",
"coords": {
"latitude": "40.7903",
"longitude": "-73.9597"
},
"window" : {
"title": "Manhattan New York, NY"
}
}
];
return {
markers: Markers
};
});
然后在你的
gMap controller
$scope.markers = Markers.markers;
更新:
您还需要导入
angular-simple-logger.js
fiidle