@angular/forms#NgForm TypeScript Examples
The following examples show how to use
@angular/forms#NgForm.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: app.component.ts From blog2020 with MIT License | 6 votes |
submit(form: NgForm): void {
const formData = new FormData();
formData.append('email', form.value.email);
formData.append('username', form.value.username);
formData.append('h-captcha-response', form.value.captcha);
this.httpClient.post<boolean>('/signup', formData).subscribe(
ok => {
if (ok) {
this.toastController.create({
message: 'Sign up successful.',
duration: 4000
}).then(toast => toast.present());
} else {
this.toastController.create({
message: 'Something wrent wrong.',
duration: 4000
}).then(toast => toast.present());
}
}
);
}
Example #2
Source File: toggle.widget.ts From ng-devui-admin with MIT License | 6 votes |
@Component({
selector: 'da-toggle-widget',
templateUrl: './toggle.widget.html',
viewProviders: [ { provide: ControlContainer, useExisting: NgForm }]
})
export class ToggleWidget implements OnInit {
@Input() ui: ToggleUI;
@Input() name: string;
constructor() { }
ngOnInit() {
}
}
Example #3
Source File: login.component.ts From Developing-Multi-platform-Apps-with-Visual-Studio-Code with MIT License | 6 votes |
login(loginForm: NgForm){
if(loginForm && loginForm.valid){
let userName = loginForm.form.value.userName;
let password = loginForm.form.value.password;
if(this.authService.login(userName, password)){
this.router.navigate([this.authService.redirectUrl]); //On Success redirect to agent or requester page
}
else{
//Show error message
this.loginErrorMessage = true;
}
}
}
Example #4
Source File: form-item.component.ts From alauda-ui with MIT License | 6 votes |
constructor(
private readonly cdr: ChangeDetectorRef,
@Optional() private readonly auiForm: FormDirective,
@Optional() ngForm: NgForm,
@Optional() formGroup: FormGroupDirective,
) {
this.parentForm = formGroup || ngForm;
if (this.auiForm) {
this.subscribeInputsFromParent();
}
}
Example #5
Source File: drawing-dialog.ts From ASW-Form-Builder with MIT License | 6 votes |
onSubmit(aswEditPropertyForm: NgForm): void {
if (aswEditPropertyForm.invalid) {
return;
}
// this.model.displayName = this.control.displayName;
// this.model.controlType = this.control.controlType;
// this.model.name = this.name;
// this.model.label = this.label;
// this.model.tooltip = this.tooltip;
// if (this.control.controlType !== 'radio' || this.control.controlType !== 'checkbox') {
// this.model.style = this.style;
// }
// this.model.isRequired = this.isRequired;
// this.model.options = this.options;
// this.dialogRef.close(this.model);
}
Example #6
Source File: file-input.component.ts From angular-material-components with MIT License | 6 votes |
constructor(protected _elementRef: ElementRef<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>,
protected _platform: Platform,
private _cd: ChangeDetectorRef,
@Optional() @Self() public ngControl: NgControl,
@Optional() _parentForm: NgForm,
@Optional() _parentFormGroup: FormGroupDirective,
_defaultErrorStateMatcher: ErrorStateMatcher) {
super(_defaultErrorStateMatcher, _parentForm, _parentFormGroup, ngControl);
this.id = this.id;
if (this.ngControl) {
this.ngControl.valueAccessor = this;
}
}
Example #7
Source File: support.ts From actions-test with Apache License 2.0 | 6 votes |
async submit(form: NgForm) {
this.submitted = true;
if (form.valid) {
this.supportMessage = '';
this.submitted = false;
const toast = await this.toastCtrl.create({
message: 'Your support request has been sent.',
duration: 3000
});
await toast.present();
}
}
Example #8
Source File: login.component.ts From EDA with GNU Affero General Public License v3.0 | 6 votes |
public login(form: NgForm) {
if (form.invalid) {
return;
} else {
const user = new User(null, form.value.email, form.value.password);
this.userService.login(user, form.value.remember).subscribe(
() => {
if (this.urlParams) {
const params = this.urlParams.split('&')
let newParams: any = {};
for (const param of Object.keys(params)) {
if (params[param].split('=')[1].split('%7C')[1]) {
let paramSplit = params[param].split('=')[1].split('%7C');
newParams[params[param].split('=')[0]] = paramSplit.join('|');
} else {
newParams[params[param].split('=')[0]] = params[param].split('=')[1];
}
}
this.router.navigate([this.returnUrl], { queryParams: newParams });
} else {
this.router.navigate([this.returnUrl]);
}
},
err => Swal.fire('Error al iniciar sesiĆ³n', err.text, 'error')
);
}
}
Example #9
Source File: add-vulns-to-host-external.component.ts From Smersh with MIT License | 6 votes |
onSubmit(form: NgForm): void {
const data = {
...form.value,
vuln: this.selectedVuln,
host: this.host['@id'],
impact: this.selectedImpact,
currentState: this.currentStateUser,
};
const callback = (body) =>
this.hostVulnsService.insert(body).then(
() => {
this.openSnackBar('vulnerability added');
this.router.navigateByUrl(
MissionRouter.redirectToShow(this.missionId)
);
},
(err) => {
this.openSnackBar('Error : ' + err.error['hydra:description']);
}
);
if (this.image) {
this.mediaObjectsService.insert(this.image).then(({ ['@id']: id }) => {
data.image = id;
callback(data);
});
} else {
callback(data);
}
}
Example #10
Source File: cue-points-player.component.ts From ngx-videogular with MIT License | 6 votes |
onSubmit(form: NgForm, event: Event) {
event.preventDefault();
if (form.valid) {
const jsonData = {
title: form.value.title,
description: form.value.description,
src: form.value.src,
href: form.value.href
};
const jsonText = JSON.stringify(jsonData);
this.track.addCue(
new VTTCue(form.value.startTime, form.value.endTime, jsonText)
);
}
}
Example #11
Source File: certified-model-add.component.ts From distributed-compliance-ledger with Apache License 2.0 | 6 votes |
onSubmit(form: NgForm, model: ComplianceInfo) {
if (!form.valid) {
this.showValidation = true;
return;
}
const message = new MsgCertifyModel(model);
this.txService.goPreview(message, '/model-info/' + model.vid + '/' + model.pid);
}
Example #12
Source File: edit-vuln-with-state.component.ts From Smersh with MIT License | 6 votes |
onSubmit(form: NgForm): void {
this.hostvulnService.update(this.id, form.value).then(
() => {
this.openSnackBar('Host updated');
this.router.navigateByUrl(MissionRouter.redirectToList());
this.ngOnInit();
},
(err) => {
if (err.status === '400') {
this.openSnackBar('Error : ' + err.error['hydra:description']);
}
}
);
}
Example #13
Source File: textarea.widget.ts From ng-devui-admin with MIT License | 6 votes |
@Component({
selector: 'da-textarea-widget',
templateUrl: './textarea.widget.html',
viewProviders: [ { provide: ControlContainer, useExisting: NgForm }]
})
export class TextAreaWidget implements OnInit {
@Input() ui: TextAreaUI;
@Input() name: string;
constructor() { }
ngOnInit() {
}
}
Example #14
Source File: mission-single.component.ts From Smersh with MIT License | 6 votes |
addHost(form: NgForm): void {
this.hostsService
.insert({
...form.value,
checked: false,
mission: this.mission['@id'],
})
.then(
() => {
this.ngOnInit();
form.reset();
},
(err) => {
if (err.status === '400') {
this.openSnackBar('Error : ' + err.error['hydra:description']);
}
}
);
}
Example #15
Source File: base-scan.component.ts From IntelOwl-ng with GNU Affero General Public License v3.0 | 5 votes |
@Input() scanForm: NgForm;
Example #16
Source File: login.component.ts From angular-9-firebase-chat-example with MIT License | 5 votes |
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
const isSubmitted = form && form.submitted;
return !!(control && control.invalid && (control.dirty || control.touched || isSubmitted));
}
Example #17
Source File: upload-assets.component.ts From assetMG with Apache License 2.0 | 5 votes |
isErrorState(
control: FormControl | null,
form: FormGroupDirective | NgForm | null
): boolean {
return control.dirty && form.invalid;
}
Example #18
Source File: edit-sales.component.ts From mean-stack-angular-9-realtime-crud with MIT License | 5 votes |
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
const isSubmitted = form && form.submitted;
return !!(control && control.invalid && (control.dirty || control.touched || isSubmitted));
}
Example #19
Source File: add-cases.component.ts From angular-9-coronavirus-cases-app with MIT License | 5 votes |
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
const isSubmitted = form && form.submitted;
return !!(control && control.invalid && (control.dirty || control.touched || isSubmitted));
}
Example #20
Source File: login.ts From actions-test with Apache License 2.0 | 5 votes |
onLogin(form: NgForm) {
this.submitted = true;
if (form.valid) {
this.userData.login(this.login.username);
this.router.navigateByUrl('/app/tabs/schedule');
}
}
Example #21
Source File: missionsCreate.component.ts From Smersh with MIT License | 5 votes |
onSubmit({ value }: NgForm): void {
super.onSubmit({
value: {
...value,
period: this.period.value,
},
} as NgForm);
}
Example #22
Source File: show-error.component.ts From workflow-editor with Educational Community License v2.0 | 5 votes |
constructor(ngForm: NgForm) {
this.form = ngForm.form;
}
Example #23
Source File: doraErrorStateMatcher.ts From HeartBeat with MIT License | 5 votes |
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
const isSubmitted = form && form.submitted;
return !!(control && control.invalid && (control.dirty || control.touched || isSubmitted));
}
Example #24
Source File: formErrorStateMatcher.ts From tuxedo-control-center with GNU General Public License v3.0 | 5 votes |
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
const invalidCtrl = !!(control && control.invalid && control.parent.dirty);
const invalidParent = !!(control && control.parent && control.parent.invalid && control.parent.dirty);
return (invalidCtrl || invalidParent);
}
Example #25
Source File: error-input.component.ts From matx-angular with MIT License | 5 votes |
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
const isSubmitted = form && form.submitted;
return !!(control && control.invalid && (control.dirty || control.touched || isSubmitted));
}
Example #26
Source File: login.ts From WiLearning with GNU Affero General Public License v3.0 | 5 votes |
onLogin(form: NgForm) {
this.submitted = true;
if (form.valid) {
this.login();
}
}
Example #27
Source File: generic-form.component.ts From Smersh with MIT License | 5 votes |
onSubmit(_: NgForm): void {}
Example #28
Source File: url-validator.directive.spec.ts From one-platform with MIT License | 5 votes |
@ViewChild('form')
ngForm: NgForm;
Example #29
Source File: edit-filter.component.ts From worktez with MIT License | 5 votes |
@ViewChild('form') form: NgForm;