$ionicPopup onTap function


#1

Hi, I have the following popup:

$ionicPopup.show({
    title: "Find your friends...",
    template: '<input type="text" ng-model="searchTerm">',
    scope: $scope,
    buttons: [
      {
        text: "Search",
        onTap: function(e) {
          console.log($scope.searchTerm);
          //Do other stuff here...
        }
      }
    ]
  });

My problem is that the $scope.searchTerm is showing as undefined in the above example. Have I made an error in my code? Or have I misunderstood something more fundamental?

Thanks,
David.


#2

make it like this

$scope.searchTerm.text

and

template: '<input type="text" ng-model="searchTerm.text">',

this is scoping problem of models in angular. always have the model as property of an object.


#3

Ah, that works now thanks.

Obviously $scope.searchTerm = { text: “”} is initiated earlier in the code.