angular-material

array resets back mat checkbox - angular

百般思念 提交于 2020-01-06 06:44:52
问题 i am trying to store the checked value in an array, it is an object since it also consists data for the row. component.html <ng-container matColumnDef="actions"> <th mat-header-cell *matHeaderCellDef> Action </th> <td mat-cell *matCellDef="let row; let i = index"> <mat-checkbox (change)="$event ? selection.toggle(row) : null" [checked]="selection.isSelected(row)"> </mat-checkbox> </td> </ng-container> component.ts close() { this.selectedData[this.data.myKey] = this.selection.myValue; this

How can I create an Angular Material Design table with infinite columns, for known number of rows?

夙愿已清 提交于 2020-01-06 05:40:10
问题 I have created an HTML table which will generate infinite columns based on the number of rows in the input data. I've tried to use this SO post as an example, but I'm struggling to convert my HTML to Angular Material design. Any suggestions? StackBlitz demo Since Angular material tables are column-based (and I couldn't find a way to iterate over the rows within them) I got stuck pretty quickly. I couldn't get angular material tables working in the StackBlitz, so here is a copy paste of my

How can I create an Angular Material Design table with infinite columns, for known number of rows?

眉间皱痕 提交于 2020-01-06 05:40:07
问题 I have created an HTML table which will generate infinite columns based on the number of rows in the input data. I've tried to use this SO post as an example, but I'm struggling to convert my HTML to Angular Material design. Any suggestions? StackBlitz demo Since Angular material tables are column-based (and I couldn't find a way to iterate over the rows within them) I got stuck pretty quickly. I couldn't get angular material tables working in the StackBlitz, so here is a copy paste of my

How to access data from 2 different mat-tree in angular?

て烟熏妆下的殇ゞ 提交于 2020-01-06 05:28:08
问题 in my project, I am using 2 different trees from angular material. I created a demo on stackblitz here : https://stackblitz.com/edit/angular-wvbg5j. When I try to access their data, I use treeControl.dataNodes but it only gives me the data from the latest generated tree ("groceries2 and reminders2 tree). It displays dataNodes in the console each time I check/uncheck an item. So I don't know what to do, is there another way to access tree data? or is there a function that stores both trees in

To avoid components overlapping in angular

夙愿已清 提交于 2020-01-06 05:26:18
问题 I have two components called customer-details and customer-bookings which are called by their selectors in app.component.html file as shown in below code <app-customer-details></app-customer-details> <app-customer-bookings></app-customer-bookings> The components should look like this(i,e one below the other). But it is overlapping like this. Here i am facing overlapping issues,I tried to solve it by setting height to 50vh for each component. But i want to solve this overlapping issue without

Angular Datepicker change dateformat

本小妞迷上赌 提交于 2020-01-06 05:22:05
问题 i use the DatePicker from Angular Material and I would like to change the output format to yyyy/mm/dd . Currently it prints the date in the following format: Wed Nov 14 2018 00:00:00 GMT+0100 (Central European Normal Time) How can I do this? datepicker = new FormControl('', [Validators.required]); console.log(this.datepicker.value.toString()); 回答1: You can use Moment.js to format your date to "YYYY/MM/DD" format moment(this.datepicker.value).format('YYYY/MM/DD') using moment will help us

Not able to set initial pageIndex in mat-paginator when dealing with large datasets

十年热恋 提交于 2020-01-06 04:55:12
问题 From this SO post i learned that in order to deal with large datasets you should set dataSource.paginator before dataSource.data in ngAfterViewInit. However when doing this I am not able to set an initial pageIndex using this.paginator.pageIndex. https://stackblitz.com/edit/angular-mat-table-v2 When I load my data in ngOnInit and the paginator after this in ngAfterViewInit, I am able to set the initial pageIndex: https://stackblitz.com/edit/angular-mat-table-v1 回答1: You can try this: ngOnInit

To enable or disable the input field based on the value of select component in angular

耗尽温柔 提交于 2020-01-06 04:44:05
问题 I am having 2 component select and input component.as shown in below image. Scenario: Here by default i have set input field as disabled .If i choose some option from select component then the field becomes active.This scenario is working fine. Expected Result: I should have another option in the select component(i,e dropdown) to disable the input field again(If user doesn't want want choose anything from select component). Here is the stackblitz link. 回答1: You have to do some editings. in

angularjs 2 with angular-material @angular/core not found

不想你离开。 提交于 2020-01-06 04:08:08
问题 I want to use angular2 with angular-material. Below is my package.json { "name": "angular2-boilerplate", "version": "1.0.0", "scripts": { "lite": "lite-server", "gulp": "gulp", "start": "concurrent \"npm run gulp\" \"npm run lite\" " }, "license": "ISC", "dependencies": { "@angular2-material/button": "^2.0.0-alpha.2", "@angular2-material/checkbox": "^2.0.0-alpha.2", "@angular2-material/core": "^2.0.0-alpha.2", "@angular2-material/progress-circle": "^2.0.0-alpha.2", "@angular2-material/toolbar

How to populate mat-select with angular material?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-06 03:37:31
问题 Hey I'm trying to use angular material and I'm having an issue. In my project I get movies details such as title,year,genre and so on. I'm trying to make an edit popup and when I got to the genre edit I got a little problem. how can I populate the select line with genres the movie already has? lets say for example I want the default value to be: "Action,Comedy". my html: <mat-select placeholder="Genre" [formControl]="genre" multiple> <mat-option *ngFor="let genre of genresList" value="Action