我正在创建一个 AngularJS + Ionic 应用程序,并尝试在用户单击按钮时显示弹出消息。
这是 index.html:
<body ng-app="starter">
<ion-content ng-controller="HomeCtrl">
<button class="button button-block button-positive" ng-click="showpop()">
<i class="icon ion-ionic"></i>
</ion-content>
</body>
这是控制器。我没有输入真实数据。
angular.module('starter.controllers', [])
.controller('HomeCtrl', function($scope, $ionicPopup , $timeout) {
$scope.showpop = function() {
var alertPopup = $ionicPopup.alert({
title: 'Don\'t eat that!',
template: 'It might taste good'
});
alertPopup.then(function(res) {
console.log('Thank you for not eating my delicious ice cream cone');
});
};
});
当我单击按钮时,弹出窗口不起作用。我不知道错误在哪里。