Angularjs 无法缩小JS

Angularjs 无法缩小JS,angularjs,minify,atom-editor,yui-compressor,Angularjs,Minify,Atom Editor,Yui Compressor,在实施Firebase身份验证之前,此JS文件已成功缩小,没有任何问题 使用none midifyed版本时,文件工作没有任何问题,我无法测试minifyed版本,因为由于以下错误,Atom将不允许我缩小和保存(见附件) 我正在使用并遵循Scotch.io的建议: 任何指点/建议都很好 错误 控制器JS var fbcontrollers = angular.module('fbcontrollers', []); fbcontrollers.controller('authCtrl', ['

在实施Firebase身份验证之前,此JS文件已成功缩小,没有任何问题

使用none midifyed版本时,文件工作没有任何问题,我无法测试minifyed版本,因为由于以下错误,Atom将不允许我缩小和保存(见附件)

我正在使用并遵循Scotch.io的建议:

任何指点/建议都很好

错误

控制器JS

var fbcontrollers = angular.module('fbcontrollers', []);
fbcontrollers.controller('authCtrl', ['$scope', 'Auth', '$location', function($scope, Auth, $location) {
  $scope.auth = Auth;
  $scope.user = $scope.auth.$getAuth();
  // Store User Data
  function userData() {
    var isNewUser = true;
    var fire = new Firebase('https://courtyard-bridal.firebaseio.com/');
    fire.onAuth(function(authData) {
      if (authData && isNewUser) {
        fire.child("users").child(authData.uid).set({
          name: getName(authData),
          email: getEmail(authData),
          provider: authData.provider
        });
      }
      function getName(authData) {
        switch (authData.provider) {
          case 'password':
            return authData.password.email.replace(/@.*/, '');
          case 'facebook':
            return authData.facebook.displayName;
        }
      }
      function getEmail(authData) {
        switch (authData.provider) {
          case 'password':
            return authData.password.email;
          case 'facebook':
            return authData.facebook.email;
        }
      }
    });
  }
  // Facebook Login
  $scope.fblogin = function() {
    var scope = {
      scope: 'email'
    };
    $scope.auth.$authWithOAuthPopup('facebook', scope).then(function(auth) {
      // Store Data
      userData();
      // Redirtect on Success
      $location.path('/dash');
    }).catch(function(error) {
      console.log('error');
    });
  };
  // Default Form Data
  $scope.form = ({
    'email': '',
    'password': ''
  });
  // Login Form
  $scope.login = function() {
    var email = $scope.form.email;
    var password = $scope.form.password;
    $scope.authData = null;
    $scope.auth.$authWithPassword({
      email: email,
      password: password
    }).then(function(Auth) {
      $scope.authData = Auth;
      $location.path('/dash');
    }).catch(function(error) {
      console.log(error);
    });
  };
  // Register (Create User) Form
  $scope.register = function() {
    var email = $scope.form.email;
    var password = $scope.form.password;
    // Create User
    $scope.auth.$createUser({
      email: email,
      password: password
    }).then(function(Auth) {
      // Store Data
      userData();
      // Login Created User
      $scope.authData = null;
      $scope.auth.$authWithPassword({
        email: email,
        password: password
      }).then(function(Auth) {
        $scope.authData = Auth;
        $location.path('/dash');
      }).catch(function(error) {
        console.log('error');
      });
    }).catch(function(error) {
      console.log(error);
    });
  };
}]);
fbcontrollers.controller('dashCtrl', ['$scope', 'Auth', '$location', function($scope, Auth, $location) {
  $scope.auth = Auth;
  $scope.user = $scope.auth.$getAuth();

  if($scope.user.provider === 'facebook') {
    $scope.id = $scope.user.uid;
    $scope.name = $scope.user.facebook.displayName;
    $scope.email = $scope.user.facebook.email;
    $scope.profile = $scope.user.facebook.profileImageURL;
  } else if ($scope.user.provider === 'password') {
    $scope.id = $scope.user.uid;
    $scope.name = $scope.user.password.email.replace(/@.*/, '');
    $scope.email = $scope.user.password.email;
    $scope.profile = $scope.user.password.profileImageURL;
  }
  console.log($scope.user);

  // Logout
  $scope.logout = function() {
    $scope.auth.$unauth();
    $location.path('/auth');
  };
}]);

我很确定这个问题与使用
catch
有关。请注意,
catch
是javascript中的一个关键字,用于异常(错误)处理。承诺使用
catch
作为方法名,这有点冲突。一般来说,间接使用它更安全:

}).then(function(...) {
   ...
})['catch'](function(error) {
   ...
});

这同样适用于
finally
关键字。

catch
是javascript中的一个关键字。使用
['catch']
更安全,例如
})