3

だから私はAngularに慣れていないので、Angular.JSのYeoman足場をダウンロードして少しいじりました。このライブラリを使用して Facebook ログインを実装しようとしています: https://github.com/pc035860/angular-easyfb 何も読み込まれておらず、コンソールに何も反映されていません。この問題は、コントローラーへの facebook 依存関係の注入と関係があるとほぼ確信しています。私はこれを私のmain.jsファイルに持っています:

angular.module('circeApp', ['ezfb'])
  .controller('MainCtrl', function($scope, ezfb, $window, $location) {
  updateLoginStatus(updateApiMe);

  $scope.login = function(){
  ezfb.login(function(response){
      if(response.authResponse){
      updateLoginStatus(updateApiMe);
      }
  }, {scope: 'email,user_likes'});
  };

  $scope.logout = function(){
  ezfb.logout(function(){
      updateLoginStatus(updateApiMe);
  });
  };

  function updateLoginStatus(more){
  ezfb.getLoginStatus(function(response){
      $scope.loginStatus = response;

      (more || anular.noop)();
  });
  }

  function updateApiMe(){
  ezfb.api('/me', function(response){
      $scope.apiMe = response;
  });
  }
});

そして、これは私のapp.jsファイルで:

'use strict';

angular.module('circeApp', [
  'ngCookies',
  'ngResource',
  'ngSanitize',
  'ngRoute',
  'ezfb'
])
  .config(function ($routeProvider, $locationProvider, $httpProvider, ezfbProvider) {
    $routeProvider
      .when('/', {
        templateUrl: 'partials/main',
        controller: 'MainCtrl'
      })
      .when('/login', {
        templateUrl: 'partials/login',
        controller: 'LoginCtrl'
      })
      .when('/signup', {
        templateUrl: 'partials/signup',
        controller: 'SignupCtrl'
      })
      .when('/settings', {
        templateUrl: 'partials/settings',
        controller: 'SettingsCtrl',
        authenticate: true
      })
      .otherwise({
        redirectTo: '/'
      });

    $locationProvider.html5Mode(true);

    // Intercept 401s and redirect you to login
    $httpProvider.interceptors.push(['$q', '$location', function($q, $location) {
      return {
        'responseError': function(response) {
          if(response.status === 401) {
            $location.path('/login');
            return $q.reject(response);
          }
          else {
            return $q.reject(response);
          }
        }
      };
    }]);
  })
  .run(function ($rootScope, $location, Auth) {

    // Redirect to login if route requires auth and you're not logged in
    $rootScope.$on('$routeChangeStart', function (event, next) {

      if (next.authenticate && !Auth.isLoggedIn()) {
        $location.path('/login');
      }
    });

//Configure ezfb provider aqui
   ezfbProvider.setInitParams({
       appId: 'XXXXXXXXXXXX',
       status: true,
       cookie: true,
       xfbml: true
   });
  });

この前に、ページがレンダリングされましたが、コンソールから「引数 'MainCtrl' は関数ではありません。定義されていません」と言われました。不足している括弧を修正し、ezfb が angular.module に含まれていることを確認しました。今、私が得る唯一のものは空白のページです。

4

0 に答える 0