angular2-forms

angular 2 group validation

ぃ、小莉子 提交于 2020-01-04 05:29:07
问题 Given simple registration form: this.registerForm = this.formBuilder.group({ email:['', Validators.compose([ Validators.required, Validators.pattern('.+@.+\..+'), ]), this.validators.isTaken], matchingPassword: this.formBuilder.group({ password: ['', Validators.compose([ Validators.required, Validators.maxLength(30), Validators.minLength(8) ])], passwordConfirmation: ['', Validators.compose([ Validators.required, ])] }, {validator: this.validators.match}) }) I'm trying to validate password

Angular2 RC6 HttpModule manual injection

回眸只為那壹抹淺笑 提交于 2020-01-04 02:09:52
问题 I'm migrating a project from angular2 RC4 to RC6 and I have a custom Form Validator which needs Http . Before the migration I used the ReflectiveInjector with the HTTP_PROVIDERS , but with RC6 this is not possible anymore as HTTP_PROVIDERS is deprecated, respectively not present anymore. This is the static method in the Validator: static checkVat(control: FormControl) { let checkVatUrl = "http://localhost:8080/checkvat"; let injector = ReflectiveInjector.resolveAndCreate([HTTP_PROVIDERS]);

how to convert byte array to image in Angular2

丶灬走出姿态 提交于 2020-01-03 02:22:09
问题 I am getting byte array from api and i have applied image tag on my HTML page as <img src="data:{{model.asd_logo_type}};base64,{{model.dfgh_logo}}" alt="..."> but i am not able to get the image on display. Please suggest what can i do. 回答1: you can use src directive to display image in angular <img [src]="'data:image/jpeg;base64,'+model.dfgh_logo" /> This is how I achieved. model.dfgh_logo this should have image in byte array. 来源: https://stackoverflow.com/questions/48781966/how-to-convert

Add Text to an Existing Input Field on Button Click

心已入冬 提交于 2020-01-02 22:05:42
问题 I am creating a site where admins on the site will routinely post articles (much like a blog). I as an admin can write a basic HTML document easily, but the other admins are not at all familiar with HTML. I have a form that they will use to publish their articles with author, title, and content fields. I am currently taking the 'content' field and displaying it as HTML after the form is submitted. To help the other users I have added buttons that say "header", "paragraph", "image", and "line

Add Text to an Existing Input Field on Button Click

别说谁变了你拦得住时间么 提交于 2020-01-02 22:05:23
问题 I am creating a site where admins on the site will routinely post articles (much like a blog). I as an admin can write a basic HTML document easily, but the other admins are not at all familiar with HTML. I have a form that they will use to publish their articles with author, title, and content fields. I am currently taking the 'content' field and displaying it as HTML after the form is submitted. To help the other users I have added buttons that say "header", "paragraph", "image", and "line

Angular 2.3.1 async custom validator promise doesn't resolve

主宰稳场 提交于 2020-01-02 06:19:09
问题 I've got a sign up form and I want to check that if the username is already taken or not. To achieve this I'm using promises now. My sign up component looks like this: import { Component, OnInit } from '@angular/core'; import { FormControl, FormBuilder, FormGroup, Validators } from '@angular/forms'; import { UserService } from '../shared/user.service' @Component({ selector: 'app-auth', providers: [], templateUrl: './auth.component.html', styleUrls: ['./auth.component.css'] }) export class

Angular2 beta: nesting form-based parent/child components and validating from parent

若如初见. 提交于 2020-01-02 05:22:07
问题 I'm trying to implement in Angular2 (beta 0 with TS in the Plunker) a scenario with 2 nested forms, each represented by a component. The parent component is Word , which represents the word in a fake dictionary. The children components are WordSense 's, each representing a sense of the parent word. Both the components use model-driven forms, and the child form binds its model's values to form controls using ngModel . This way, the parent component can easily pass its word's senses down to the

touched/untouched not updating in custom input component - Angular 2

守給你的承諾、 提交于 2020-01-02 00:14:09
问题 I have a custom input component that is updating validation and states with the exception of touched/untouched. Everything else state-wise (pristine/dirty) works as expected. Here's a plunker: https://plnkr.co/edit/O9KWzwhjvySnXd7vyo71 import { Component, OnInit, Input, ElementRef, forwardRef, Renderer } from '@angular/core'; import { REACTIVE_FORM_DIRECTIVES, Validator, Validators, NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms'; export const CUSTOM_INPUT_CONTROL_VALUE

touched/untouched not updating in custom input component - Angular 2

雨燕双飞 提交于 2020-01-02 00:14:05
问题 I have a custom input component that is updating validation and states with the exception of touched/untouched. Everything else state-wise (pristine/dirty) works as expected. Here's a plunker: https://plnkr.co/edit/O9KWzwhjvySnXd7vyo71 import { Component, OnInit, Input, ElementRef, forwardRef, Renderer } from '@angular/core'; import { REACTIVE_FORM_DIRECTIVES, Validator, Validators, NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms'; export const CUSTOM_INPUT_CONTROL_VALUE

Angular2 No provider for ControlContainer when building a simple form

非 Y 不嫁゛ 提交于 2020-01-01 04:29:08
问题 This is my form: app.component.html <form [ngFormModel]="myForm"> <my-child-component></my-child-component> </form> app.component.ts constructor ( private _formBuilder : FormBuilder ) { this.myForm = _formBuilder.group( { firstName : ["",Validators.required] } ); } my-child-component: <input type="text" ngControl="firstName"> Error: No provider for ControlContainer [ERROR ->]<md-input ngControl="firstName" placeholder="First name"> If I move the input inside the app component itself, it'll