angular2-forms

angular2 checkbox formcontrol

我只是一个虾纸丫 提交于 2019-12-12 07:49:27
问题 For a simple checkbox with a string value bound to a FormControl: export class CheckboxComponent { formControl: FormControl; option: {value: string}; constructor() { this.formControl = new FormControl(); this.option = {value: "MyValue"}; this.formControl.valueChanges.subscribe(console.log); } } <input type="checkbox" [formControl]="formControl" [value]="option.value" name="SomeName" /> The output of the subscribe is true, false, true, false.... I want the angular 2 to bind the string value

Angular4 radio button binding not working with reactive forms

瘦欲@ 提交于 2019-12-12 05:59:42
问题 Just switched from Angular2 (where my code worked with no problem) to Angular4. I have a true value bound to one of my radio buttons, but the radio button is not selected when the view renders. Condensed version of code shown below: My component: // all relevant imports... ... export class My Component{ public form: FormGroup = this.formBuilder.group({ prop1: ''}); constructor(private formBuilder: FormBuilder){ this.form.patchValue({prop1: true}); } } view: <form [formGroup]="form"> <input

Angular2 Auto suggester

夙愿已清 提交于 2019-12-12 05:58:56
问题 I have been searching a lot on INTERNET but still unable to figure out how i can make custom auto suggester without any third party. After a lot of google I found this but the issue is that my response from api is a bit different i am getting response as : [{"id":"1","name":"aa"},{"id":"2","name":"bb"}...] due to which i am getting [object][object] as value in pipe. Can anyone please help how i can handle this request with this pipe. I want that their should be a text box on whose click there

Which @angular/forms version for angular 2 RC7?

帅比萌擦擦* 提交于 2019-12-12 04:24:19
问题 I'm in the process of upgrading an Angular 2 app from RC5 to RC7. @angular/forms package version is 0.3.0, and I could not find a newer one. Still, in 2.0.0-rc.6 the Type declaration was deprecated in favour of Type<T> . But it looks like forms package needs to be updated, as now when building I got a bunch of errors like: ERROR in [default] path/to/my/project/node_modules/@angular/forms/src/directives.d.ts:26:45 Generic type 'Type' requires 1 type argument(s). Does anyone know if there's a

angular2 cannot read property 'validator' of undefined when use ngFormModel (ES6)

你离开我真会死。 提交于 2019-12-12 04:06:07
问题 I got some problem when use ngFormModel directive with form it said "TypeError: Cannot read property 'validator' of undefined in form_one (I write this code from NG-BOOK 2 Tutorial but it's not work!) import {Component} from 'angular2/core' import { FORM_DIRECTIVES, FormBuilder, ControlGroup, Validators } from 'angular2/common' @Component({ selector: 'demo-form-sku-builder', directives: [FORM_DIRECTIVES], template: ` <div class="ui raised segment"> <h2 class="ui header">Demo Form: Sku with

Event not working in dynamic html in angular2

放肆的年华 提交于 2019-12-12 03:58:21
问题 Want to append the dynamic generated html in a DOM, its appending successfully in a DOM but none of the function is working like click etc. ngOnInit() { this.sideBarData += '<li class="sidebar-toggler-wrapper hide" >' + '<div class="sidebar-toggler" > </div>' + '</li>' + '<li class="sidebar-search-wrapper"></li>'; this.sideBarData += '<li class="nav-item start">' + '<a class="nav-link home name" (click)="HomeButton(event)">' + '<i class="fa fa-home"></i>' + '<span class="title">Home</span>' +

ionic 2: add custom input component in a FORM within a page / Final goal: integrate “cordova-plugin-datepicker” in Ionic 2 Form

做~自己de王妃 提交于 2019-12-12 03:52:10
问题 In ionic 2 version: Cordova CLI: 6.4.0, Ionic Framework Version: 2.0.0-rc.0, Ionic CLI Version: 2.1.0, Ionic App Lib Version: 2.1.0-beta.1,OS: Node Version: v6.7.0 With Ionic 2 FORM, the input: <ion-datetime> happens to be slow (see here) . I want to go around it and use the "cordova-plugin-datepicker" instead. I have many question about it to make it work. But I'll start here with the first step I need to achieve: To implement a custom selector that can be use as a <ion-[something for a form

Angular 2 Checkbox value with Reactive form

邮差的信 提交于 2019-12-12 03:28:57
问题 i have checkbox in angular 2 reactive form i need to pass the values of these checkbox in POST api , Right now they will pass value on status. below are checkbox code it only passed the status like true or false instead of value like 1,2 something like that. <input type="checkbox" formControlName="servicelatest" [value]="CatArry[i].id" (change)="serviceCheckBox($event)"/> -------------------**------------------------ <div *ngFor="let serviceType of laceDetailFrom.controls.serviceType.controls

Angular 2 - Inject ngModel in custom directive when html field has formControlName

天涯浪子 提交于 2019-12-12 03:16:01
问题 I have tried using a custom attribute in a field provided by a directive (class with @Directive) that I created, and this directive has NgForm injected in the constructor, but it doesn't work if the field has the formControlName attribute. Here is the plunker of a demo: http://plnkr.co/edit/gdm3Xb?p=preview Situation The field is bound with ngModel with two-way bind, because I use the model for updating directly the fields when I want (or need) or sending data to the server. In processes like

Login with linkedin and get user information in Angular2

谁都会走 提交于 2019-12-12 02:33:31
问题 I am new to Angular2, I want to integrate linked login functionality and get the currently singed in user information for my Angular2 project. I have created App in using linkedin developer account and have Client ID and Client Secret and tried below code but it gives me error ZoneAwareError {__zone_symbol__error: Error: You must specify a valid JavaScript API Domain as part of this key's configuration. at ht……} I tried both the way for declaring api key using double quotes ( api_key: