$ionicPopup onTap function

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.

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.

Ah, that works now thanks.

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