2017-04-10 78 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 –