2017-04-10 39 views
0

爲什麼我的$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.'; 
    }); 
}; 
+0

您正在使用哪個版本,因爲'.prompt'只能從v1.1.0rc1及以上版本獲得。 – anoop

+0

我正在使用1.3.15版,所以還有其他方式可以使用它。 –

回答

1

$mdDialog.prompt()僅適用於v1.1.0rc1

Here是工作示例和here是GitHub的問題

請檢查版本,並相應地使用可用的功能。

謝謝。

+0

使用它的最佳解決方案是我使用的方式1.3.15 –

+0

@RamanaUday它是您的Angular Material版本還是Angular版本? –

+0

對不起材料版本是1.0.0和角度版本是1.3.15 –