Problem with binding info in popup


#1

Hi,

I’m having weird issues that I can’t seem to find an explanation for.
I show a popup with a single input which I am binding to a variable on my scope I’m passing the $scope to the popup.
The binding works and I can see the variable that is set and it changes as I type. But as soon as I close the popup and log out that scope variable on the “on tap” function" it seems to go back to its original value.

EDIT: a pen that demonstrated the general issue:

code:

var sendPopup = $ionicPopup.show({
     title: $translate.instant(popupTitle),
     subTitle: $translate.instant('POPUP_WITH_MESSAGE_SUBTITLE'),
     templateUrl:  'templates/leave-message-popup.html',
     scope: $scope,
     buttons: [
      { text: $translate.instant('BUTTON_CANCEL') },
      {
        text: $translate.instant('BUTTON_SEND'),
        type: 'button-positive',
        onTap: function(e) {
                console.log("contact message:" + $scope.contactMessage);
                if (!$scope.contactMessage) {
                  console.log("preventing default");
                  e.preventDefault();
                } else {
                  $scope.sendData(contactType);
                }
              }
      },
    ]


   });

template:

<input type="text" ng-model="contactMessage" name="message" placeholder="{{'PLACEHOLDER_CONTACT_MESSAGE' | translate}}" required autofocus>
{{contactMessage}}