I am trying to use an angular bootloader that loads it with npm and then browses all in one file. Details of the error can be seen here.
I can not understand the errors, because now I am still new to AngularJS. Here is my code
var angular = require('angular'); angular .module('jobApp', [require('angular-material'), require('ng-file-upload')]) .controller('MainCtrl', ['$rootScope', '$scope', '$mdToast', '$animate', '$http', '$timeout', '$q', '$log', 'Upload', function($rootScope, $scope, $mdToast, $animate, $http, $timeout, $q, $log, Upload) { 'use strict'; // Initialize the scope variables $scope.$watch('files', function () { $scope.upload($scope.files); }); $scope.upload = function (files) { if (files && files.length) { for (var i = 0; i < files.length; i++) { var file = files[i]; Upload.upload({ url: 'http://sr-recruit.herokuapp.com/resumes', fields: { 'name': $scope.name, 'email': $scope.email, 'about': $scope.about }, file: file }).progress(function (evt) { var progressPercentage = parseInt(100.0 * evt.loaded / evt.total); $scope.log = 'progress: ' + progressPercentage + '% ' + evt.config.file.name + '\n' + $scope.log; }).success(function (data, status, headers, config) { $scope.log = 'file ' + config.file.name + 'uploaded. Response: ' + JSON.stringify(data) + '\n' + $scope.log; $scope.$apply(); }); } } }; }]);
UPDATE
Now I use Browserify-shim to correctly insert the Angular-file-upload file in Commonjs format. Thanks @ryan Johnson.
Here is the .json package
{ "browser": { "angular": "./node_modules/angular/angular.js", "ng-file-upload": "./node_modules/ng-file-upload/dist/ng-file-upload-all.js" }, "browserify-shim": { "angular": { "exports": "angular" }, "ng-file-upload": { "exports": "angular.module('ngFileUpload').name" } }, "browserify": { "transform": [ "browserify-shim" ] } }
I'm still a mistake
TypeError: Cannot read property '' of undefined
I do not know why. FYI I am using Laravel-elixir built into the browser to complete the task.