Javascript angularJs文件中的use strict命令出错
我的代码怎么了?我不明白。我所做的一切都是在: ,但我得到了Javascript angularJs文件中的use strict命令出错,javascript,angularjs,Javascript,Angularjs,我的代码怎么了?我不明白。我所做的一切都是在: ,但我得到了意外令牌)MainController.js:42 代码如下: (function() { 'use strict'; angular .module('FindItApp') .controller('MainController',MainControllerFunction); function MainControllerFunction($scope,places){ angular.ext
意外令牌)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);
});
})();
因为你错过了那一行的
}
,你忘了关上你的第一个括号
在第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.
})();
(函数(){
"严格使用",;
有棱角的
.module('FindItApp')
.控制器(“主控制器”,主控制器功能);
函数MainControllerFunction($scope,places){
角度。扩大范围{
地图中心:{
拉脱维亚:40.741934,
液化天然气:-74.004897,
缩放:16
},
图层:{
基层:{
谷歌地形:{
名称:'谷歌地形',
图层类型:“地形”,
键入:“谷歌”
},
谷歌混合:{
名称:'谷歌混合',
layerType:“HYBRID”,
键入:“谷歌”
},
谷歌路线图:{
名称:'谷歌街道',
图层类型:“路线图”,
键入:“谷歌”
}
}
}
});
地点.成功(功能(数据){
$scope.geodata=数据;
$scope.mapMarkers=geodatamarkers($scope.geodata);
});
}//修复缩进。然后您会发现缺少一个}
。是的,我检查了10次此代码,但没有看到:/Thx for open my eyesPosting链接到您的代码有助于获取上下文,但您应该始终在问题中包含相关代码。
(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.
})();