I'm trying to use ng-file-upload in my simple angular js project but when I try to do npm install
I get the error below
js/controllers/HomePageController.js: line 18, col 11, Expected '{' and instead saw '$scope'. js/controllers/HomePageController.js: line 23, col 4, Missing semicolon.
My JS folder is like below
.
├── app_module.js
├── controllers
│ └── HomePageController.js
└── directives
├── GreetBox.js
└── HomePageGreetingBox.js
and I have the following code in HomePageController.js
angular.module('app').controller('HomePageController', ['$scope', 'Upload', '$timeout', function ($scope, Upload, $timeout) {
'use strict';
$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));
});
}
}]);
and the code in app_module.js
is below
;(function (angular) {
'use strict';
angular.module('app', []);
})(angular);
Removing use string Gives the following error
➜ 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.
Remove the 'use strict';
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));
});
}
}]);