我想編寫一個簡單的「確認離子彈出」,但我有這個問題,我無法解決。我敢肯定,如果你看一看,你會發現它,因爲現在它就像我反對完全失明......Ionic PopUp: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>
謝謝!
我好笨!感謝很多人的工作! :) – Memphis