Angularjs 第18行第11列预期为“{”,但看到的是“$scope”
我尝试在我的简单angular js项目中使用,但是当我尝试进行npm安装时,我得到了下面的错误 js/controllers/HomePageController.js:第18行第11列应为“{” 而是看到了“$scope”.js/controllers/HomePageController.js:line 23,第4列,缺少分号 我的JS文件夹如下所示Angularjs 第18行第11列预期为“{”,但看到的是“$scope”,angularjs,ng-file-upload,Angularjs,Ng File Upload,我尝试在我的简单angular js项目中使用,但是当我尝试进行npm安装时,我得到了下面的错误 js/controllers/HomePageController.js:第18行第11列应为“{” 而是看到了“$scope”.js/controllers/HomePageController.js:line 23,第4列,缺少分号 我的JS文件夹如下所示 . ├── app_module.js ├── controllers │ └── HomePageController.js └──
.
├── app_module.js
├── controllers
│ └── HomePageController.js
└── directives
├── GreetBox.js
└── HomePageGreetingBox.js
我在HomePageController.js中有以下代码
下面是app_module.js中的代码
删除使用字符串
给出以下错误
➜ angular-skeleton git:(master) ✗ npm install && node server.js
> angular-skeleton@0.0.0 postinstall /Users/anthony/code/angular/angular-skeleton
> bower install && node_modules/.bin/gulp
bower angular extra-resolution Unnecessary resolution: angular#~1.5.0
[12:37:40] Using gulpfile ~/code/angular/angular-skeleton/gulpfile.js
[12:37:40] Starting 'clean'...
[12:37:40] Finished 'clean' after 4.22 ms
[12:37:40] Starting 'lint'...
[12:37:40] Starting 'views'...
[12:37:40] Starting 'app'...
[12:37:40] Starting 'vendor'...
[12:37:40] Starting 'css'...
[12:37:40] Finished 'css' after 6.84 ms
js/controllers/HomePageController.js: line 2, col 5, Missing "use strict" statement.
js/controllers/HomePageController.js: line 16, col 13, Expected '{' and instead saw '$scope'.
js/controllers/HomePageController.js: line 21, col 6, Missing semicolon.
删除“严格使用”一词
angular.module('app').controller('HomePageController', ['$scope', 'Upload', '$timeout', function ($scope, Upload, $timeout) {
$scope.greetingText = 'Get to somehrere!';
$scope.uploadPic = function(file) {
file.upload = Upload.upload({
url: 'https://angular-file-upload-cors-srv.appspot.com/upload',
data: {username: $scope.username, file: file},
});
file.upload.then(function (response) {
$timeout(function () {
file.result = response.data;
});
}, function (response) {
if (response.status > 0)
$scope.errorMsg = response.status + ': ' + response.data;
}, function (evt) {
// Math.min is to fix IE which reports 200% sometimes
file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
});
}
}]);
现在我发现一个错误,缺少use strict语句。它应该在外面。对不起,在哪里?我是AngularJS的新手。你有团队查看器吗?或者在plunkerI上共享你的代码我刚刚安装了团队查看器。我如何授予你查看代码的权限?
➜ angular-skeleton git:(master) ✗ npm install && node server.js
> angular-skeleton@0.0.0 postinstall /Users/anthony/code/angular/angular-skeleton
> bower install && node_modules/.bin/gulp
bower angular extra-resolution Unnecessary resolution: angular#~1.5.0
[12:37:40] Using gulpfile ~/code/angular/angular-skeleton/gulpfile.js
[12:37:40] Starting 'clean'...
[12:37:40] Finished 'clean' after 4.22 ms
[12:37:40] Starting 'lint'...
[12:37:40] Starting 'views'...
[12:37:40] Starting 'app'...
[12:37:40] Starting 'vendor'...
[12:37:40] Starting 'css'...
[12:37:40] Finished 'css' after 6.84 ms
js/controllers/HomePageController.js: line 2, col 5, Missing "use strict" statement.
js/controllers/HomePageController.js: line 16, col 13, Expected '{' and instead saw '$scope'.
js/controllers/HomePageController.js: line 21, col 6, Missing semicolon.
angular.module('app').controller('HomePageController', ['$scope', 'Upload', '$timeout', function ($scope, Upload, $timeout) {
$scope.greetingText = 'Get to somehrere!';
$scope.uploadPic = function(file) {
file.upload = Upload.upload({
url: 'https://angular-file-upload-cors-srv.appspot.com/upload',
data: {username: $scope.username, file: file},
});
file.upload.then(function (response) {
$timeout(function () {
file.result = response.data;
});
}, function (response) {
if (response.status > 0)
$scope.errorMsg = response.status + ': ' + response.data;
}, function (evt) {
// Math.min is to fix IE which reports 200% sometimes
file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
});
}
}]);