I can't minify Angular files with gulp

var gulp = require('gulp') var concat = require('gulp-concat') var sourcemaps = require('gulp-sourcemaps') var uglify = require('gulp-uglify') var ngAnnotate = require('gulp-ng-annotate') gulp.task('js', function() { var source = ['components/itunseApp.js', 'components/factory.js', 'components/config.js', 'components/directive.js', 'components/viewCtrl.js']; return gulp.src(source) .pipe(sourcemaps.init()) .pipe(concat('all.min.js', { newLine: ';' })) .pipe(ngAnnotate({ add: true })) .pipe(uglify({ mangle: true })) .pipe(sourcemaps.write('./')) .pipe(gulp.dest('components')); }); gulp.task('watch', ['js'], function() { gulp.watch('components/*.js', ['js']) }) 

The controller on which gives an error

 itunseApp.controller('viewCtrl', ['$scope', '$location', '$routeParams', 'itunesSearch', function($scope, $location, $routeParams, itunesSearch) { console.log('viewCtrl'); $scope.categoryParam = window.localStorage.getItem('categoryParam') || ''; $scope.searchParam = window.localStorage.getItem("searchParam") || ''; switch ($scope.categoryParam) { case "song": $scope.entity = 'song'; $scope.idParam = $routeParams.collectionId || window.localStorage.getItem('idParam'); break; case "music-video": $scope.entity = 'musicVideo'; $scope.idParam = $routeParams.trackId || window.localStorage.getItem('idParam'); break; case "software": $scope.entity = 'software'; $scope.idParam = $routeParams.trackId || window.localStorage.getItem('idParam'); break; case "feature-movie": $scope.entity = 'movie'; $scope.idParam = $routeParams.trackId || window.localStorage.getItem('idParam'); break; } itunesSearch.getInfo("http://itunes.apple.com/lookup", $scope.searchParam, $scope.entity, $scope.arrayParams, $scope.idParam).then(data => { $scope.arrayParams = data.array; }); window.localStorage['idParam'] = $scope.idParam; 

}]);

Specifically, these two lines he does not like

 itunesSearch.getInfo("http://itunes.apple.com/lookup", $scope.searchParam, $scope.entity, $scope.arrayParams, $scope.idParam).then(data => { $scope.arrayParams = data.array; }); 

This is a separately written factory.

screen with an error

http://joxi.ru/n2YeQPRsooQp92

    2 answers 2

    not sure, but maybe it swears because an exception is not handled when http is requested? try

     itunesSearch.getInfo("http://itunes.apple.com/lookup", $scope.searchParam, $scope.entity, $scope.arrayParams, $scope.idParam).then(data => { $scope.arrayParams = data.array; }, error => console.log(error)); 

      Found the error correctly needed to write like this

        itunesSearch.getInfo("http://itunes.apple.com/lookup", $scope.searchParam, $scope.entity, $scope.arrayParams, $scope.idParam).then(function(data) { $scope.arrayParams = data.array; }); 

      Ie gulp did not want to eat "=>"

      • one
        so can make him eat transpiled files? gulp-babel should help with this. - Mr. Brightside