angular2-forms

How to fix error Cannot find name 'object' in angular 2 cli ckeditor

懵懂的女人 提交于 2019-12-13 16:14:12
问题 I have insalled ng2-ckeditor using cli : npm install ng2-ckeditor --save Then Include CKEditor javascript files in my index file : <script src="https://cdn.ckeditor.com/4.5.11/full/ckeditor.js"></script> Then imported module in module file: import { CKEditorModule } from 'ng2-ckeditor'; in imports "CKEditorModule" and trying to use in html It show error: ERROR in /var/www/html/eventswebsite/frontendapp/node_modules/ng2-ckeditor/lib/ckeditor.component.d.ts (43,26): Cannot find name 'object'.

Custom validation for positive numbers

落花浮王杯 提交于 2019-12-13 14:00:40
问题 I was trying to find the information, if there are any built-in validators, that check if the input is a positive number? I was trying to build the following: static nonZero(control:Control) { if (Number(control.value) < 0) { control.setErrors({nonZero: true}) } else { control.setErrors(null) } } However, I didn't know how to use it in my form builder: this.form = _formBuilder.group({ field:['', Validators.required]}) What am I doing wrong? 回答1: You can configure it this way by leveraging the

Set value of <mat-select> programmatically

帅比萌擦擦* 提交于 2019-12-13 11:36:25
问题 I'm trying to set value of 2 fields <input matInput> abnd <mat-select> programatically. For text input everything works as expected however for the <mat-select> on the view this field is just like it would have value off null . But if I would call console.log(productForm.controls['category'].value it prints correct value that I set programmatically. Am I missing something? Here is the code: form config: productForm = new FormGroup({ name: new FormControl('', [ Validators.required ]), category

How to add pop up date pickar using ngX-bootstrap?

Deadly 提交于 2019-12-13 08:19:10
问题 How to add datepickar using ngx-bootstrap? This project uses Angular2 typescript2 ngx-bootstrap. I am doing following things: In HTML : <datepicker class="well well-sm main-calendar" [(ngModel)]="dt" [minDate]="minDate" [showWeeks]="false" [dateDisabled]="dateDisabled"></datepicker> In Module: import { DatepickerModule } from 'ngx-bootstrap/datepicker'; @NgModule({ imports: [ DatepickerModule.forRoot() ]}); 回答1: The feature does not currently exist in the library. There is a discussion on it

Display username of user who logs in (Angular 2)

心不动则不痛 提交于 2019-12-13 07:39:25
问题 This seems like a very simple question but I'm new to Angular2 and I'm a bit confused by the relationship between components. I have a login page and when the user enters their username, I want the username to display on the dashboard, something like "Welcome, James". I have a login.html page, a loginHTMLcomponent that has a templateurl to the login.html page and its parent which login.ts. I have dashboard.ts which is a parent of dashboard.component.ts which (has the HTML for the dashboard

Angular4 search filter functionality on Entire table

梦想与她 提交于 2019-12-13 04:33:32
问题 Here i Implemented small search filter on a table But My Requirement is its should search whole the table not within the page? search <label> Search FRom Table:</label> <input (change)="someval($event.target.value)"> someval(value){ let data=JSON.stringify(value); console.log(data.length); this.auction.find(e=>e.uniqueid=data); this.GetDashBoardData(); } GetDashBoardData(){ var somedata= this.globalService.getBasicInfoData(); this.auctionRequest = { "loginId": this.userdata.LoginID }; return

Angular: Bind date picked from bootstrap-datepicker to underlying ngModel or formControlName

大兔子大兔子 提交于 2019-12-13 03:33:40
问题 I'm using bootstrap-datepicker in my Angular project by creating it as a directive. Below is my code. HTML: <input [datepicker]="datepickerConfig" readonly ngModel name="requestedDate" class="form-control" id="requestedDate" type="text"> Datepicker config in component: datepickerConfig = { format: 'dd-M-yyyy' }; Directive: @Directive({ selector: '[datepicker]' }) export class DatepickerDirective implements OnInit { @Input() datepicker; constructor(private el: ElementRef) { } ngOnInit() { $

Getting issue in registering contorl with form in Angular Reactive forms

白昼怎懂夜的黑 提交于 2019-12-13 02:48:05
问题 I am working on Angular Reactive forms. Initially I have an formarray in formgroup. afterwards I push formgroup into formarray to add form control dynamically. I am getting an issue when binding these control using formControlName. I am getting this Error: Cannot find control with path: 'controlArray -> 0 -> value' here is my component class code: ngOnInit(){ this.reviewForm = this.fb.group({ 'controlArray': new FormArray([]) }); this.showDefaultForm(); } First I am getting data in formsDb,

How to do simple cross field validation in Angular 2 form to pass validation if one of the control in group has value?

梦想与她 提交于 2019-12-13 00:46:44
问题 This is so commonly used, there must be a simple way to approach this! So here is the situation. I have a form group: <ion-item-group formGroupName="alternativeRevenue"> <ion-item-divider color="primary" text-wrap sticky>Alternative revenue </ion-item-divider> <ion-item> <ion-label>Branded content</ion-label> <ion-toggle formControlName="brandedContent"></ion-toggle> </ion-item> <ion-item text-wrap *ngIf="businessFoundationsForm.get('alternativeRevenue.brandedContent').value"> <ion-label

Angular 2 - Get the value of changed FormControl in Observable

ぃ、小莉子 提交于 2019-12-12 23:20:06
问题 I have a simple Form built with FormBuilder : this.contactForm = formBuilder.group({ 'name': [''], 'email': [''], 'phone': [''], }); I want to watch every control for changes, and run a function with the updated value when this happens: getContacts(value: any) { this.phoneContacts.findContact(value).then( contacts => { // do something } ); } Right now, I'm doing this for every control, using bind to have access to the this object of the component: this.contactForm.get('name').valueChanges