爲什麼我的$mdDialog.prompt
不工作,而$mdDialog.confirm
對我來說工作正常嗎?
我已經使用的代碼是:
$scope.showPrompt = function(ev) {
var confirm = $mdDialog.prompt()
.title('What would you name your dog?')
.textContent('Bowser is a common name.')
.placeholder('dog name')
.ariaLabel('Dog name')
.ok('Okay!')
.cancel('I\'m a cat person');
$mdDialog.show(confirm);
}
在此我得到錯誤控制檯作爲TypeError: $mdDialog.prompt is not a function
但是,如果使用下面的代碼是工作的罰款:
$scope.showPrompt = function(event) {
var confirm = $mdDialog.confirm()
.title('Are you sure to delete the record?')
.textContent('Record will be deleted permanently.')
.ariaLabel('TutorialsPoint.com')
.targetEvent(event)
.ok('Yes')
.cancel('No');
$mdDialog.show(confirm).then(function() {
$scope.status = 'Record deleted successfully!';
}, function() {
$scope.status = 'You decided to keep your record.';
});
};
您正在使用哪個版本,因爲'.prompt'只能從v1.1.0rc1及以上版本獲得。 – anoop
我正在使用1.3.15版,所以還有其他方式可以使用它。 –