angular4-forms

Property 'controls' does not exist on type 'AbstractControl' - angular4

血红的双手。 提交于 2019-12-04 20:13:50
问题 there are lots of blogs already posted for this error but none is specified for angular4. I am adding and removing dynamic controls on the form add controls to the form during intialization ngOnInit() { this.lienHolder = this._fb.group({ emailAddress: ['', [Validators.required, Validators.email]], policyDetails: this._fb.array([ this.initPolicyTemplate(), ]) }); } initPolicyTemplate() { return this._fb.group({ policyNumber: ['', [Validators.required, Validators.pattern("(^[^0][A-Z]{1}[0-9]*$)

Passing on all directives to a child element of the component

白昼怎懂夜的黑 提交于 2019-12-04 18:12:02
问题 I have a few custom directives which are basically designed for <input> . And I have a custom component <app-decorated-input> There are a ton <app-decorated-input> s along with simple <input> s in my application for some of which I like to use the directives and for others I don't. How do I pass on the directives to the underlying <input> when the directive is used like so: <app-decorated-input directive1 directive2 ></app-decorated-input> and have the same effect of the directives on the

ng-bootstrap not working in angular 4

北城以北 提交于 2019-12-04 16:27:54
问题 I am new with angular 4, I am trying to configure bootstrap. I installed ng-bootstrap: https://ng-bootstrap.github.io/#/getting-started I did all like on the page, but I don't see the bootstrap on my page. Here is my code: src/app/app.module.ts import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { AppComponent } from './app.component'; import { FormsModule } from '@angular/forms'; import {NgbModule} from '@ng-bootstrap/ng-bootstrap';

angular material 2 custom component with ng value accessor

左心房为你撑大大i 提交于 2019-12-04 07:09:29
I a working on angular 4.4 + material beta12 custom component and not able to figure out what is wrong in my implementation I am trying to achieve the below custom input Task: set value to formControl, once I got data from server(data.productTeam is data-can see in code) on edit, formcontrol should be updated with values (eg:P12DT2H231M) Issues: I am not able to bind default value to formcontrol. Without ngDefaultControl (No value accessor for form control with name: 'productTeam' error occuring) dashboard.component.js this.CRForm = this.fb.group({ productTeam: [data.productTeam || ''] }); In

Angular 2 / 4 : How to POST HTML form (Not ajax) thru component on callback of 1st ajax submit?

蓝咒 提交于 2019-12-04 05:31:34
I want to submit form to external site by POSTing the input fields in old school way(non Ajax) , it submits too but Angular giving me error in console before jumping to external page. I used following code in HTML(template) <form (submit)="onSubmit($event)" method="POST" [formGroup]="form" *ngIf='form' action="https://www.sandbox.paypal.com/cgi-bin/webscr" > In component onSubmit(obj: any) { if (!this.form.valid) { this.helper.makeFieldsDirtyAndTouched(this.form); } else { this.loader = true; // save data in online_payment_ipn this.paymentService.saveOnlinePaymentIpn({}, 'paypal') .subscribe

at least one field is required in angular 4 forms

北城余情 提交于 2019-12-03 17:19:05
I'm using angular 4 forms and I have some fields. and first_name, last_name and company are really important for me. I want to force the user to fill one of these 3 fields. how can I do it? here are .ts codes: this.contactForm = this.fb.group({ first_name: [null, Validators.compose([Validators.required])], last_name: [null, Validators.compose([Validators.required])], email: [null, Validators.compose([this.validateEmail])], company: [null], position: [null], }); an html: <form [formGroup]="contactForm" fxLayout="column"> <md-input-container class="data_light"> <input class="data_font capital"

How to pass all checked checkbox values on Form Submit in angular 4/6/7

天涯浪子 提交于 2019-12-03 14:15:37
I want to fetch all checked items of a form in component without using change() or click() function as it is unable to fetch already checked items. Here is my Array in TS: PartyRoles = [ { Id: 1, Name: "Vendor", Checked: true }, { Id: 2, Name: "Client", Checked: true }, { Id: 3, Name: "Consigner", Checked: false } ] My HTML Form: <form (ngSubmit)="editPartyRolesSubmit()"> <div *ngFor="let item of PartyRoles"> <label> <input type="checkbox" value="{{item.Id}}" [attr.checked]="item.Checked==true ? true : null" [attr.disabled]="item.Id==1 ? true : null" /> <span innerHTML="{{item.Name}}"></span>

Passing on all directives to a child element of the component

烈酒焚心 提交于 2019-12-03 11:50:44
I have a few custom directives which are basically designed for <input> . And I have a custom component <app-decorated-input> There are a ton <app-decorated-input> s along with simple <input> s in my application for some of which I like to use the directives and for others I don't. How do I pass on the directives to the underlying <input> when the directive is used like so: <app-decorated-input directive1 directive2 ></app-decorated-input> and have the same effect of the directives on the underlying <input> as if it were used directly on it: <input type="text" directive1 directive2 > UPDATE:

ng-bootstrap not working in angular 4

笑着哭i 提交于 2019-12-03 10:30:18
I am new with angular 4, I am trying to configure bootstrap. I installed ng-bootstrap: https://ng-bootstrap.github.io/#/getting-started I did all like on the page, but I don't see the bootstrap on my page. Here is my code: src/app/app.module.ts import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { AppComponent } from './app.component'; import { FormsModule } from '@angular/forms'; import {NgbModule} from '@ng-bootstrap/ng-bootstrap'; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, FormsModule, // add this NgbModule

Charts in Angular 2+

那年仲夏 提交于 2019-12-03 08:26:48
问题 I want to create a graph similar to the picture I have attached or may be a bar graph. I am using Angular 4 and I have no idea about graphs in Angular. Is a reference link or some sample code available? [![Graph][1]][1] 回答1: We can achieve your requirement by using Syncfusion angular-charts . For more details about Syncfusion angular-charts please find attached demo and FT links. Sample: https://stackblitz.com/edit/angular-zo5arc?file=src/app/app.module.ts Screenshot: FT: https://www