我正在尝试理解Ionic框架的工作原理以及如何使用控制器。更具体地说,我正在尝试通过文档中的一些代码向滑动条示例添加一个显示警报/弹出窗口的按钮。但是,不幸的是没有成功。我不确定如何调试应用程序,因为Ionic服务器与模拟器不一致。有没有好的教程(不是官方页面)?最好的方法是什么?我进展太慢了。顺便说一下,我熟悉iOS编码,并且有点想念舒适的iOS环境...
以下是我为按钮警报单击编写的代码:在其中一个HTML文件中
<button ng-click="showPopup()" class="button icon ion-edit"></button>
在controllers.js文件中
.controller('PlaylistsCtrl',function($scope, $ionicPopup, $timeout) {
// Triggered on a button click, or some other target
$scope.showPopup = function() {
$scope.data = {}
// An alert dialog
$scope.showAlert = 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');
});
};
};
});
修复了 感谢您的输入。我会尝试修复它。我意识到这不是ionic,而是angularjs,我现在找到了一本好书可以阅读。谢谢
$scope.showAlert
从未被调用。 - merlin