我想在模态上获取生成的JSON结果。我可以知道怎么办吗?目前,当结果出现时,我无法让模态滑入。
显示TypeError: $scope.modal is undefined
.controller('formcontrol', function($scope, $http, $ionicLoading, $ionicModal){
$scope.show = function() {
$ionicLoading.show({
template: 'Loading...'
});
};
$scope.search = function(data){
if($scope.fsearchr.$pristine){
alert('Nothing to search.');
}else{
data = {
'text' : $scope.searchr.text,
};
$ionicLoading.show({template:'Searching....'});
$http.post( l + 'search.php', data).
success(function(data, status, headers, config) {
$ionicModal.fromTemplateUrl('#/tab/result.html', function($ionicModal) {
$scope.modal = $ionicModal;
}, {
scope: $scope,
animation: 'slide-in-up',
});
console.log('show the freaking modal');
$ionicLoading.hide();
//$scope.modal.show();
}).
error(function(data, status, headers, config) {
// called asynchronously if an error occurs
// or server returns response with an error status.
alert('Error. No result.');
});
}
}
})
答案 0 :(得分:0)
$ionicModal.fromTemplateUrl()
不接受函数参数。它返回ionicModal类的一个实例,您可以将其用作模式对话框的句柄。
var modal = $ionicModal.fromTemplateUrl('#/tab/result.html', {
scope: $scope,
animation: 'slide-in-up',
});
modal.open();