Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 2015ae8

Browse files
mdklabkara
authored andcommitted
feat(prompt): implement "required" flag for prompt dialogs (#10626)
Fixes #10135
1 parent 2602e7b commit 2015ae8

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/components/dialog/demoBasicUsage/script.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ angular.module('dialogDemo1', ['ngMaterial'])
4646
.ariaLabel('Dog name')
4747
.initialValue('Buddy')
4848
.targetEvent(ev)
49+
.required(true)
4950
.ok('Okay!')
5051
.cancel('I\'m a cat person');
5152

src/components/dialog/dialog.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ function MdDialogProvider($$interimElementProvider) {
598598
})
599599
.addPreset('prompt', {
600600
methods: ['title', 'htmlContent', 'textContent', 'initialValue', 'content', 'placeholder', 'ariaLabel',
601-
'ok', 'cancel', 'theme', 'css'],
601+
'ok', 'cancel', 'theme', 'css', 'required'],
602602
options: advancedDialogOptions
603603
});
604604

@@ -616,15 +616,16 @@ function MdDialogProvider($$interimElementProvider) {
616616
' </div>',
617617
' <md-input-container md-no-float ng-if="::dialog.$type == \'prompt\'" class="md-prompt-input-container">',
618618
' <input ng-keypress="dialog.keypress($event)" md-autofocus ng-model="dialog.result" ' +
619-
' placeholder="{{::dialog.placeholder}}">',
619+
' placeholder="{{::dialog.placeholder}}" ng-required="dialog.required">',
620620
' </md-input-container>',
621621
' </md-dialog-content>',
622622
' <md-dialog-actions>',
623623
' <md-button ng-if="dialog.$type === \'confirm\' || dialog.$type === \'prompt\'"' +
624624
' ng-click="dialog.abort()" class="md-primary md-cancel-button">',
625625
' {{ dialog.cancel }}',
626626
' </md-button>',
627-
' <md-button ng-click="dialog.hide()" class="md-primary md-confirm-button" md-autofocus="dialog.$type===\'alert\'">',
627+
' <md-button ng-click="dialog.hide()" class="md-primary md-confirm-button" md-autofocus="dialog.$type===\'alert\'"' +
628+
' ng-disabled="dialog.required && !dialog.result">',
628629
' {{ dialog.ok }}',
629630
' </md-button>',
630631
' </md-dialog-actions>',

0 commit comments

Comments
 (0)