我的代码出了什么问题?我不会理解。我做了所有事情就像在this guide中一样:
,但我得Unexpected token ) MainController.js:42
。
以下是代码:
(function() {
'use strict';
angular
.module('FindItApp')
.controller('MainController',MainControllerFunction);
function MainControllerFunction($scope,places){
angular.extend($scope, {
mapCenter:{
lat: 40.741934,
lng: -74.004897,
zoom: 16
},
layers: {
baselayers: {
googleTerrain: {
name: 'Google Terrain',
layerType: 'TERRAIN',
type: 'google'
},
googleHybrid: {
name: 'Google Hybrid',
layerType: 'HYBRID',
type: 'google'
},
googleRoadmap: {
name: 'Google Streets',
layerType: 'ROADMAP',
type: 'google'
}
}
}
});
places.success(function(data){
$scope.geodata = data;
$scope.mapMarkers = geodataToMarkers($scope.geodata);
});
})();
答案 0 :(得分:1)
因为您错过了该行的}
答案 1 :(得分:0)
您忘记关闭IIFE
的左括号在第42行中,通过更改
进行修复})();
到
}})();
或者,如果您实际修复了代码的缩进,它将如下所示:
(function() {
'use strict';
angular
.module('FindItApp')
.controller('MainController',MainControllerFunction);
function MainControllerFunction($scope,places){
angular.extend($scope, {
mapCenter:{
lat: 40.741934,
lng: -74.004897,
zoom: 16
},
layers: {
baselayers: {
googleTerrain: {
name: 'Google Terrain',
layerType: 'TERRAIN',
type: 'google'
},
googleHybrid: {
name: 'Google Hybrid',
layerType: 'HYBRID',
type: 'google'
},
googleRoadmap: {
name: 'Google Streets',
layerType: 'ROADMAP',
type: 'google'
}
}
}
});
places.success(function(data){
$scope.geodata = data;
$scope.mapMarkers = geodataToMarkers($scope.geodata);
});
} // <-- you previously had this closing bracket in line below, and the following closing bracket was missing.
})();