你怎么修复'Parse'没有定义。?

时间:2015-07-26 07:34:50

标签: parse-platform

我在client / app.js文件中不断收到此错误,因为我使用grunt将其编译为生产。我在开发之前从未遇到过这个错误。我没有找到任何关于如何在客户端修复此问题的明确指导。我在页面底部初始化Parse。

我的app.js:

'use strict';

angular.module('cpApp', [
  'ngCookies',
  'ngResource',
  'ngSanitize',
  'ui.router',
  'ui.bootstrap',
  'parse-angular',
  'angularPayments',
  'elif'
])
  .config(function ($stateProvider, $urlRouterProvider, $locationProvider, $httpProvider) {
    $urlRouterProvider
      .otherwise('/');

    $locationProvider.html5Mode(true);
      $httpProvider.interceptors.push('authInterceptor');
  })

.factory('authInterceptor', function ($rootScope, $q, $cookieStore, $location) {
  return {
    // Add authorization token to headers
    request: function (config) {
      config.headers = config.headers || {};
      if ($cookieStore.get('token')) {
        config.headers.Authorization = 'Bearer ' + $cookieStore.get('token');
      }
      return config;
    },

    // Intercept 401s and redirect you to Landing Page
    responseError: function(response) {
      if(response.status === 401) {
        $location.path('/');
        // remove any stale tokens
        $cookieStore.remove('token');
        return $q.reject(response);
      }
      else {
        return $q.reject(response);
      }
    }
  };
})


    .run(function ($rootScope, $location, Auth) {
      Parse.initialize('key1', 'key2');
      // Redirect to card if route requires auth and you're not logged in
      $rootScope.$on('$stateChangeStart', function (event, next) {
        Auth.isLoggedInAsync(function(loggedIn) {
          if (next.authenticate && !loggedIn) {
            $location.path('/');
          }
        });
      });
    });

1 个答案:

答案 0 :(得分:0)

问题出在我的配置功能中。我需要从运行中移动Parse:

.config(function ($stateProvider, $urlRouterProvider, $locationProvider, $httpProvider, Parse) {
      Parse.initialize('Id1', 'Id2');
      $urlRouterProvider
      .otherwise('/');

    $locationProvider.html5Mode(true);
      $httpProvider.interceptors.push('authInterceptor');
  })