0

I am new at this correct me if I'm wrong . I want to take the name data from the input with ng-model but i cant take the data at the onTap: function. I tried to alert $scope.name but it is empty doesnt work,then i tried $scope.name="" empty at the init but it doesnt change when the user writes his name.How can i get the name .Thank you.

`$scope.data = {

      model: "Choose",
      availableOptions: [
        {id: '1', name: 'dummyText1'},
        {id: '2', name: 'dummyText2'},
        {id: '3', name: 'dummyText3'}
      ] 
    };`
var myPopup = $ionicPopup.show({
      template:

      '<div class="list list-inset">' +
      '</label><label class="item item-input"><i class="icon ion-person placeholder-icon"></i>' +
      '<input  type="text" placeholder="Your name.." ng-model="name"></label>' +
      '</div>' ,

      title: 'Profile',
      scope: $scope,
      buttons: [
        { text: 'Cancel' },
        {
          text: '<b>Save</b>',
          type: 'button-positive',
          onTap: function(e) {
            if ($scope.name != null) {

              alert($scope.name);
              e.preventDefault();
            } else {
                alert($scope.name);

            }
          }
        }
      ]
    });

here is the popup screenshot Thank you again

erdemgunenc
  • 969
  • 3
  • 14
  • 25

1 Answers1

0

I figured out with adding ng-change="foo(data)" to input ,now im able to use this data at scope . Thank you.

erdemgunenc
  • 969
  • 3
  • 14
  • 25