我想编写一个简单的“确认离子弹出窗口”,但我遇到了无法解决的问题。我敢肯定,如果您看一下就会发现,因为现在我好像完全对它视而不见...
TypeError:无法读取未定义的属性“确认”
这是我的代码:
// Here is the start of my "directive.js" file, I have one directive and 3 controllers
var myApp = angular.module('app.directives', [])
myApp.directive('activePageHighlight', ['$rootScope', '$state', function($rootScope, $state){
// Something else
}]);
// Here is my controller
myApp.controller('MainCtrl', ['$scope', function ($scope, $ionicPopup, $timeout) {
$scope.info = function(){
var confirmPopup = $ionicPopup.confirm({
// Here I tried to add $scope, but I'm not sure if is it usefull
scope:$scope,
title: 'Consume Ice Cream',
template: '<button class="button button-primary" ng-click="info()">Confirm</button>'
});
confirmPopup.then(function(res) {
if(res) {
console.log('You are sure');
} else {
console.log('You are not sure');
}
});
};
}]);
<div ng-controller="MainCtrl">
<button ng-click="info()" class="calm button-block">Info 1</button>
</div>
谢谢 !