Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access popup scope in the tap event handlers #4446

Merged
merged 1 commit into from
Dec 6, 2015

Conversation

xxdondi
Copy link

@xxdondi xxdondi commented Sep 29, 2015

I think that it might be nice to have access to the popup scope in the onTap method. I needed to do that because my popup contained a Do not show again check box that was bound to the popup's scope and I could not access its value at all, because popup calls $new() on its scope option, if one is passed. You can basically see my code below:

$ionicPopup.show({
        scope: $scope,
        title: 'Text',
        template: '\
<div class="item item-text-wrap">\
   <!-- A very annoying message -->\
    <span>Annoying message.</span>\
</div>\
<!-- Make sure user has a chance to turn it off -->\
<ion-checkbox ng-model="doNotShow">Do Not Show Again</ion-checkbox>',
        buttons: [{
          text: 'Cancel'
        },
        {
          text: 'Continue',
          onTap: function(e) {
                // `this` is now the popup object
                // and we can have access to its scope nicely
            if(this.scope.doNotShow) {
                rememberNotToShow();
            }   
            return true;
          }
        }]
      });

mlynch added a commit that referenced this pull request Dec 6, 2015
Access popup scope in the tap event handlers
@mlynch mlynch merged commit f7eca57 into ionic-team:master Dec 6, 2015
@mlynch
Copy link
Contributor

mlynch commented Dec 6, 2015

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants