Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function(app) {
- var storeLocatorUploadController = function($scope, storeLocatorApiService) {
- $scope.init = function() {
- $scope.setVariables();
- };
- $scope.setVariables = function() {
- $scope.file = false;
- $scope.isUploading = false;
- };
- $scope.acceptSelectedFile = function(files) {
- if (files.length > 0) {
- $scope.file = files[0];
- }
- };
- $scope.uploadFile = function() {
- if (!$scope.isUploading) {
- if ($scope.file) {
- $scope.isUploading = true;
- var promise = storeLocatorApiService.uploadFile($scope.file);
- promise.then(function(response) {
- if (response) {
- console.info("Saved to server wit the filename " + response);
- }
- $scope.isUploading = false;
- }, function(reason) {
- console.info("File import falied.");
- console.info(reason.message);
- $scope.isUploading = false;
- });
- } else {
- console.info("Must select a file to import.");
- $scope.isUploading = false;
- }
- }
- };
- scope.init();
- };
- app.controller("storeLocatorUploadController", ["$scope", "storeLocatorApiService", storeLocatorUploadController]);
- }(angular.module(appName)));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement