@@ -421,6 +421,7 @@ function MdDialogDirective($$rAF, $mdTheming, $mdDialog) {
421
421
* - $mdDialogPreset#htmlContent(string) - Sets the prompt message as HTML. Requires ngSanitize
422
422
* module to be loaded. HTML is not run through Angular's compiler.
423
423
* - $mdDialogPreset#placeholder(string) - Sets the placeholder text for the input.
424
+ * - $mdDialogPreset#initialValue(string) - Sets the initial value for the prompt input.
424
425
* - $mdDialogPreset#ok(string) - Sets the prompt "Okay" button text.
425
426
* - $mdDialogPreset#cancel(string) - Sets the prompt "Cancel" button text.
426
427
* - $mdDialogPreset#theme(string) - Sets the theme of the prompt dialog.
@@ -544,7 +545,7 @@ function MdDialogProvider($$interimElementProvider) {
544
545
options : advancedDialogOptions
545
546
} )
546
547
. addPreset ( 'prompt' , {
547
- methods : [ 'title' , 'htmlContent' , 'textContent' , 'content' , 'placeholder' , 'ariaLabel' ,
548
+ methods : [ 'title' , 'htmlContent' , 'textContent' , 'initialValue' , ' content', 'placeholder' , 'ariaLabel' ,
548
549
'ok' , 'cancel' , 'theme' , 'css' ] ,
549
550
options : advancedDialogOptions
550
551
} ) ;
@@ -562,7 +563,8 @@ function MdDialogProvider($$interimElementProvider) {
562
563
' <p>{{::dialog.mdTextContent}}</p>' ,
563
564
' </div>' ,
564
565
' <md-input-container md-no-float ng-if="::dialog.$type == \'prompt\'" class="md-prompt-input-container">' ,
565
- ' <input ng-keypress="dialog.keypress($event)" md-autofocus ng-model="dialog.result" placeholder="{{::dialog.placeholder}}">' ,
566
+ ' <input ng-keypress="dialog.keypress($event)" md-autofocus ng-model="dialog.result" ' +
567
+ ' placeholder="{{::dialog.placeholder}}">' ,
566
568
' </md-input-container>' ,
567
569
' </md-dialog-content>' ,
568
570
' <md-dialog-actions>' ,
@@ -577,8 +579,14 @@ function MdDialogProvider($$interimElementProvider) {
577
579
'</md-dialog>'
578
580
] . join ( '' ) . replace ( / \s \s + / g, '' ) ,
579
581
controller : function mdDialogCtrl ( ) {
582
+ var isPrompt = this . $type == 'prompt' ;
583
+
584
+ if ( isPrompt && this . initialValue ) {
585
+ this . result = this . initialValue ;
586
+ }
587
+
580
588
this . hide = function ( ) {
581
- $mdDialog . hide ( this . $type === 'prompt' ? this . result : true ) ;
589
+ $mdDialog . hide ( isPrompt ? this . result : true ) ;
582
590
} ;
583
591
this . abort = function ( ) {
584
592
$mdDialog . cancel ( ) ;
0 commit comments