以下是ionic 中模型的使用。 可根据名称不同写多个模型
angular.module('testApp', ['ionic'])
.controller('MyController', function($scope, $ionicModal) {
$ionicModal.fromTemplateUrl('my-modal.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.goModal = modal;//定义模型名称
});
$scope.openModal = function() {
$scope.goModal.show();//显示模型
};
$scope.closeModal = function() {
$scope.goModal.hide();//隐藏模型
};
//清理模型
$scope.$on('$destroy', function() {
$scope.goModal.remove();
});
//当模型隐藏时执行
$scope.$on('goModal.hidden', function() {
// 执行语句
});
// 当模型清理删除时执行
$scope.$on('goModal.removed', function() {
// 执行语句
});
});