angular2-forms

binding angular object to model-driven form in angular2

*爱你&永不变心* 提交于 2020-01-11 11:32:51
问题 I have created custom controls(in component class) with binding objects to form element in html, but there is an error message shown in consele that I couldnt solve, actually message makes no sense(formGroup is special key why it tries to bind it ?) here is the image that I see in developer console in chrome: form.component.html: <div class="row"> <form class="from-horizontal" [formGroup]="form" formControlName="username" formControlName="email" (ngSubmit)="signup()"> <div class="form-group

How to upload file in Angular2

会有一股神秘感。 提交于 2020-01-08 16:05:11
问题 I have to submit a form along with image. i have tried this code (with multiple ways) but did't work for me. is there anyone having working demo of file uploading using angular2 please help me out. component.html <form class="form-horizontal" role="form" > <div class="form-group"> <label class="control-label col-sm-4" for="myname" style="">Name<span class="asterisk">*</span></label> <div class="col-sm-7"> <div> <input type="text" class="form-control" id="myname" [(ngModel)]="myfile.name"> <

How to upload file in Angular2

两盒软妹~` 提交于 2020-01-08 16:04:54
问题 I have to submit a form along with image. i have tried this code (with multiple ways) but did't work for me. is there anyone having working demo of file uploading using angular2 please help me out. component.html <form class="form-horizontal" role="form" > <div class="form-group"> <label class="control-label col-sm-4" for="myname" style="">Name<span class="asterisk">*</span></label> <div class="col-sm-7"> <div> <input type="text" class="form-control" id="myname" [(ngModel)]="myfile.name"> <

How to know whether it is Control or ControlGroup in Angular 2?

谁说胖子不能爱 提交于 2020-01-07 08:42:08
问题 let aa = this._formBuilder.control(""); let bb = this._formBuilder.group({ aa: aa }; I want to do something like this: if (typeof(aa) == "Control") { // do something } else if (typeof(aa) == "ControlGroup") { // do something } But right now both typeof(aa) and typeof(bb) returns object . console.log(typeof(aa)); // object console.log(typeof(bb)); // object How to know whether it is Control or ControlGroup? Thanks 回答1: You could use the instanceof operator: if (aa instanceof Control) { // do

how to implement confirm on exit in angular 4?

大憨熊 提交于 2020-01-07 08:23:46
问题 I want to know how can I implement a confirm-on-exit component so that on page refresh or leaving tab or window or screen I can execute a confirm on exit method, so that if user click OK he will leave the screen and on click on NO he will remain on same screen? Code I am using here is: import { Component, OnInit, Input, Output, HostListener } from '@angular/core'; @Component({ selector: 'confirmonexit', templateUrl: './confirm-on-exit.html' }) export class ConfirmOnExitComponent { @Input()

Fontawesome Icons appearing as boxes within primeng controls

牧云@^-^@ 提交于 2020-01-07 05:34:05
问题 I am using prime ng and I can't get the controls to appear with the icons. All I'm getting are boxes but when I use fontawesome outside the prime controls, everything works fine. I uses NPM to install. Here is my index.html page <!DOCTYPE html> <html> <head lang="en"> <base href="/" > <title>Acme Product Management</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <script src="assets/scripts/angular.min.js"><

Reactive form-validation-angular2

你。 提交于 2020-01-06 23:51:13
问题 I am able to get the values from the child but I need to validate the values in my parent component that is present or not. parent.html : <browser (notify)="onselect($event)" [template]="coreActivity" (onselect)="onselect($event)" formControlName="template" ></browser> parent.ts : export class CreateCommunityComponent implements OnInit { userForm: FormGroup; public tagarray=[]; coreActivity = [ {value: 'Professional', viewValue: 'Professional', tool: 'Forum' }, {value: 'Travel', viewValue:

ag-grid cell rendering error

萝らか妹 提交于 2020-01-06 21:09:53
问题 I am using the AG-GRID api to populate a table in my website under the main.ts file i have added the following code import { bootstrap } from 'angular2/platform/browser'; import { AppComponent } from './app.component'; import { ROUTER_PROVIDERS } from 'angular2/router'; import { AgGridModule } from 'ag-grid-ng2/main'; bootstrap(AppComponent, [ROUTER_PROVIDERS],AgGridModule); my main component.ts file is as following import { Component } from 'angular2/core'; import { GridOptions } from 'ag

Validation on Kendo UI for Angular DatePicker not working

十年热恋 提交于 2020-01-05 05:39:25
问题 I'm trying to use form validation on a Kendo UI for Angular DatePicker and it just doesn't seem to work. I'm doing the following on all other form elements: <div class="form-group row" [ngClass]="{ 'has-danger' : email.invalid && (email.dirty || email.touched) }"> <input id="email" type="text" class="form-control" [(ngModel)]="member.email" name="email" #email="ngModel" required /> </div> This works perfectly fine. But when I try the same with the Kendo UI for Angular DatePicker I get the

Cannot find control with path: angular2

让人想犯罪 __ 提交于 2020-01-04 17:08:45
问题 I'm working on a model driven form and I can't get it to add items to a list being displayed with ngFor. I'm currently getting an error when trying to iterate the list.I tried all solutions available. Error Cannot find control with path: 'categories -> 0' ts file private categories : any= [{name: 'Strict',selected : false}, {name: 'Moderate',selected : true}, {name: 'Flexible',selected : true}]; let allCategories: FormArray = new FormArray([]); for (let i = 0; i < this.categories.length; i++)