0

In my view

<button type="button"
                ng-disabled="isProcessing"
                ng-click="login.ssoFacebook()"
                class="button button-primary">
                <span class="icon icon-social-facebook"></span>
                Login Using Facebook
            </button>

When I click the button facebook doesn't work My controller

this.ssoFacebook = function(){
        // intiate
        ssoAuth.facebook.initiate()
        .then(function(customer){
            if (!customer) throw 'error system';

            authService.setCurrentSession(customer, $scope);
            $timeout(function() {
                $scope.$emit(GLOBAL_EVENTS.SYSTEM.ACCOUNT.SESSION.LOGIN_SUCCESS);
            }, 500);
            // redirect or something
            $state.go('products', {}, {reload: true});
        })
        .catch(function(error){
            $scope.$emit(GLOBAL_EVENTS.SYSTEM.ACCOUNT.SESSION.LOGIN_FAILED, error);
        });
    };

Am I doing something wrong? thanks advance

5
  • What do you mean by not working? Show full controller's code please. Commented Nov 25, 2015 at 9:28
  • can you post some more code? include the definition of your controller please Commented Nov 25, 2015 at 9:32
  • @Kamo it doesn't show pop up facebook authenticate, this is my full code controller [plnkr.co/edit/qMI6v34lDklhQmnKvoDs?p=catalogue] Commented Nov 25, 2015 at 9:35
  • 2
    can you provide how you define login in html? For woking like this with controller somewhere above you should declare ng-controller="Mycontroller as login" Commented Nov 25, 2015 at 9:47
  • Perhaps it is best to public the complete relevant html, including the ng-controller declaration and your complete controller with only the relevant function apprehended. Maybe you could actually provide more details about the nature of your error, what is your console printing and is there any network activity ongoing? So we can exclude the silly mistake of linking the desired function with your html. Commented Nov 25, 2015 at 10:58

3 Answers 3

1

Replace this code,

this.ssoFacebook = function(){
...
}

with,

$scope.login = {};
$scope.login.ssoFacebook = function(){
..
}

This may be the issue.

Sign up to request clarification or add additional context in comments.

1 Comment

@did you debug your click?
1

If you want use function from controller instead of scope, you need mark this in html in attribute ng-controller

ng-controller="ControllerName as login"

and below you can use

<button type="button"
            ng-disabled="isProcessing"
            ng-click="login.ssoFacebook()"
            class="button button-primary">
            <span class="icon icon-social-facebook"></span>
            Login Using Facebook
</button>

2 Comments

This is actually the only complete answer.
@skubski, but seems OP already use it and error somewhere else
0

Change your ng-click to ng-click="ssoFacebook()"

and in your controller change with :

$scope.ssoFacebook = function(){ ... }

1 Comment

This still wouldn't work if there is no declaration of the ng-controller attribute.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.