Reputation: 2676
I have a popup in ionic and have one textfield and one button in it. I want to press enter and want button to work and close the popup. Im wondering how to perform this action within this popup below.
var myPopup = $ionicPopup.show({
template: '<input type = "text" ng-model = "data.model"><br> '
, title: 'Name'
, scope: $scope
, buttons: [
{
text: 'Cancel'
}, {
text: '<b>Search</b>'
, type: 'button-positive'
, onTap: function (e) {
$ionicLoading.show();
$http.get(HTTPService.getHttpText() + 'Persons/' + $scope.data.model).then(function (resp) {
console.log('Success', resp);
$ionicLoading.hide();
}, function (err) {
$ionicLoading.hide();
console.error('ERR', err);
// err.status will contain the status code
})
}
}
]
});
Upvotes: 0
Views: 352
Reputation: 46
Probably you have filter the button event.
if(e.name="") -->
is $http.get working?
Upvotes: 0
Reputation: 18309
I would suggest you to use a <form>
and to set your button type="submit"
:
<form ng-submit="submitPopup()">
<button type="submit">Close</button>
</form>
In the submitPopup
function, do whatever you want and close the modal:
$scope.submitPopup = function() {
$http.get( ... );
myPopup.close();
}
Upvotes: 1