feat(forms): add option to use browser's native validation and angular forms (#13566)
Also renames NgNovalidate -> NgNoValidate Closes #13573
This commit is contained in:

committed by
Victor Berchet

parent
551fe50ebd
commit
874243279d
@ -14,7 +14,7 @@ import {NgControlStatus, NgControlStatusGroup} from './directives/ng_control_sta
|
||||
import {NgForm} from './directives/ng_form';
|
||||
import {NgModel} from './directives/ng_model';
|
||||
import {NgModelGroup} from './directives/ng_model_group';
|
||||
import {NgNovalidate} from './directives/ng_novalidate_directive';
|
||||
import {NgNoValidate} from './directives/ng_no_validate_directive';
|
||||
import {NumberValueAccessor} from './directives/number_value_accessor';
|
||||
import {RadioControlValueAccessor} from './directives/radio_control_value_accessor';
|
||||
import {RangeValueAccessor} from './directives/range_value_accessor';
|
||||
@ -45,7 +45,7 @@ export {NgSelectOption, SelectControlValueAccessor} from './directives/select_co
|
||||
export {NgSelectMultipleOption, SelectMultipleControlValueAccessor} from './directives/select_multiple_control_value_accessor';
|
||||
|
||||
export const SHARED_FORM_DIRECTIVES: Type<any>[] = [
|
||||
NgNovalidate,
|
||||
NgNoValidate,
|
||||
NgSelectOption,
|
||||
NgSelectMultipleOption,
|
||||
DefaultValueAccessor,
|
||||
|
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Directive} from '@angular/core';
|
||||
|
||||
/**
|
||||
* @whatItDoes Adds `novalidate` attribute to all forms by default.
|
||||
*
|
||||
* `novalidate` is used to disable browser's native form validation.
|
||||
*
|
||||
* If you want to use native validation with Angular forms, just add `ngNativeValidate` attribute:
|
||||
*
|
||||
* ```
|
||||
* <form ngNativeValidate></form>
|
||||
* ```
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
@Directive({
|
||||
selector: 'form:not([ngNoForm]):not([ngNativeValidate])',
|
||||
host: {'novalidate': ''},
|
||||
})
|
||||
export class NgNoValidate {
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Directive} from '@angular/core';
|
||||
|
||||
@Directive({
|
||||
selector: 'form:not([ngNoForm])',
|
||||
host: {'novalidate': ''},
|
||||
})
|
||||
export class NgNovalidate {
|
||||
}
|
Reference in New Issue
Block a user