angular-material2

Angular 2+ material mat-chip-list formArray validation

[亡魂溺海] 提交于 2020-01-13 02:41:49
问题 How do I validate that a mat-chip has been added to the mat-chip-list . I am using ReactiveForms. I have tried with the required validator. The value can be a list of names, so I need to make sure that there is atleast 1 name in my list of names before I can submit the form. If the list is empty then mat-error should display the error message. Using the required validator makes the form invalid, regardless of adding names to the list. EDIT: Reactive Forms I have tried to make a custom

Angular 2+ material mat-chip-list formArray validation

霸气de小男生 提交于 2020-01-13 02:41:09
问题 How do I validate that a mat-chip has been added to the mat-chip-list . I am using ReactiveForms. I have tried with the required validator. The value can be a list of names, so I need to make sure that there is atleast 1 name in my list of names before I can submit the form. If the list is empty then mat-error should display the error message. Using the required validator makes the form invalid, regardless of adding names to the list. EDIT: Reactive Forms I have tried to make a custom

Angular 4 with material

给你一囗甜甜゛ 提交于 2020-01-12 08:51:31
问题 I am trying to implement "Angular-Material" with Angular4. I made all setup from official site of angular material [angular.material.io][1] [1]: https://material.angular.io/guide/getting-started but when trying to run project by npm start, getting following error: node_modules/@angular/material/typings/button/button.d.ts(40,22): error TS2420: Class 'MdButton' incorrectly implements interface 'CanDisable'. Property 'disabled' is private in type 'MdButton' but not in type 'CanDisable'. node

Angular Material and Jasmine : “ No provider for InjectionToken MdDialogData! ”

痞子三分冷 提交于 2020-01-11 21:10:00
问题 I have a component which is meant to be used in an Angular Material MdDialog : @Component({ ... }) export class MyComponent { constructor(@Inject(MD_DIALOG_DATA) public data: any, public dialogRef: MdDialogRef<MyComponent>) { ... } } I am trying to Unit Test it with Jasmine : describe('MyComponent', () => { let component: MyComponent; let fixture: ComponentFixture<MyComponent>; beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ SharedTestingModule, ], declarations: [

Angular Material and Jasmine : “ No provider for InjectionToken MdDialogData! ”

我怕爱的太早我们不能终老 提交于 2020-01-11 21:09:39
问题 I have a component which is meant to be used in an Angular Material MdDialog : @Component({ ... }) export class MyComponent { constructor(@Inject(MD_DIALOG_DATA) public data: any, public dialogRef: MdDialogRef<MyComponent>) { ... } } I am trying to Unit Test it with Jasmine : describe('MyComponent', () => { let component: MyComponent; let fixture: ComponentFixture<MyComponent>; beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ SharedTestingModule, ], declarations: [

Custom Component MdDatePicker used in reactive Form

别来无恙 提交于 2020-01-11 13:15:18
问题 I am trying to create a custom component to be used in a angular formGroup. Here's is how I want to use this custom component: <form [formGroup]="form"> ... <app-date-picker formControlName="dateStart" [isConsultation]="isConsultation" [label]="'Du'" [(ngModel)]="agenda.datDeb"> </app-date-picker> ... </form> Problem : In the main component (containing this form), The model doesn't get updated when the value changes in my custom component, which is involving a MdDatePicker. Though I am using

Custom Component MdDatePicker used in reactive Form

孤街浪徒 提交于 2020-01-11 13:15:09
问题 I am trying to create a custom component to be used in a angular formGroup. Here's is how I want to use this custom component: <form [formGroup]="form"> ... <app-date-picker formControlName="dateStart" [isConsultation]="isConsultation" [label]="'Du'" [(ngModel)]="agenda.datDeb"> </app-date-picker> ... </form> Problem : In the main component (containing this form), The model doesn't get updated when the value changes in my custom component, which is involving a MdDatePicker. Though I am using

How to use md-table with services in Angular 4

拈花ヽ惹草 提交于 2020-01-10 08:24:05
问题 I am quite new in the angular world and i'm trying to use the new md-table component in Angular Material 2 with Angular 4. I've made a service from an API which retrieves simple arrays of content. Now I'm trying to use this service as a data source for the md-table but I can't find a way to get the data from the service (it always return me an empty array). Please note that before using md-table, I was using already using the service and it worked normally. Here is the code for the component

Angular material 2 - input box not rendering properly as expected

时间秒杀一切 提交于 2020-01-06 06:42:47
问题 I am using Angular material 2 for angular 4 application along with angular flex layout. Below is the simple form <div fxLayoutGap="5px" fxLayout="column"> <mat-form-field class="full-width"> <input matInput placeholder="Email Id" type="text" [(ngModel)]="emailId"> </mat-form-field> <mat-form-field class="full-width"> <input matInput placeholder="Password" type="password" [(ngModel)]="password"> </mat-form-field> <mat-form-field class="full-width"> <input matInput placeholder="Confirm Password

Angular Validators: Can I add styling to form elements based on their validators?

青春壹個敷衍的年華 提交于 2020-01-06 05:43:07
问题 I'm using Angular with Forms version 4.1.0 and Material version 2.0.0-beta.8. I have fields that need to be marked as required based on a configuration stored in a database table, so the specific fields that are required can change depending on that configuration and are not known at development time. I am dynamically setting Validators.required on my form controls based on that configuration, and that is all working fine (i.e. the appropriate fields are turning red if you leave them blank