angular-material2

How to pass json data received from service to an array in component in angular material for angular 4

时光总嘲笑我的痴心妄想 提交于 2019-12-03 14:15:37
问题 I am new to Angular 4 and angular material and i am trying to add the angular material data table with http, pagination, sorting and filtering into my dashboard component, With hard-coded array i was able to achieve filter, sort and pagination. But i am not able to pass a json data from service into the array. Any help would be appreciated. Thanks in advance..!!! Please find my code below. test.json [{ "FirstName": "Jill", "LastName": "Smith", "Score": "disqualified" }, { "FirstName": "Eve",

Change default background color of md-slider of Angular Material

。_饼干妹妹 提交于 2019-12-03 13:54:51
问题 I am using md-slider of Angular Material version 2.0.0-beta.8 I have selected the indigo-pink theme and imported it in style.css I am pretty happy with what I have, but I would like to change just the background color of the slider handle and of the thumbnail . Apparently this is set by the following css code defined in the indigo-pink.css file: .mat-accent .mat-slider-thumb, .mat-accent .mat-slider-thumb-label, .mat-accent .mat-slider-track-fill{background-color:#ff4081} In fact, if I change

Angular4 Material md-table Column Width AutoSizing Like Normal Table

左心房为你撑大大i 提交于 2019-12-03 13:13:24
I'm using an md-table in an Angular 4 app since I'm using Material for other parts of the UI formatting. When I use a regular table with basically no CSS, the columns auto-format to fit the widest td element. With md-table, the columns are all set to the same width divided into the total table width, except for cells that are too wide and then it extends the cell and pushes the other cells in that row to the right. My regular table: <md-tab label="Data" > <md-card class="datacard"> <md-card-content> <div> <table class="datatable"> .... </table> </div> </md-card-content> </md-card> </md-tab>

How to filter a mat-tree component Angular Material 6.0.1

拟墨画扇 提交于 2019-12-03 12:58:03
问题 I'm using mat-tree angular material component. It's a nice component with some very useful features like, multi-select, expand all/collapse all. I was not able to find any tree filtering feature in any of their APIs. Has anyone came across this feature or done any work around to get mat-tree filter? 回答1: I solved the problem by creating a new data source(filtered). stackblitz sample I will explain the example of the shared link: I filtered the data with filter(filterText: string) in

Angular Material 2 DataSource filter with nested object

删除回忆录丶 提交于 2019-12-03 12:10:23
问题 I have angular 4 project with material 2, I want to filter the data in MatTable. DataSource filter is working fine when we filter data on field which are not nested. this.dataSource = new MatTableDataSource([ { orderNumber: 1, orderInfo: { type: 'ABC'}, date: '12/3/2012 9:42:39 AM'}, { orderNumber: 3, orderInfo: { type: 'Hello' }, date: '12/2/2018 9:42:39 AM'}, ]); Filter is working fine for orderNumber, date but not working properly with type field in orderInfo object. 回答1: DataSource has

does angular material have a grid system?

拜拜、爱过 提交于 2019-12-03 12:01:49
I'm starting a project with angular material. Does it have a native system for positioning elements in a responive grid like bootstrap does ? Otherwise is it ok practice to combine material design with bootstrap for the grid system ? Maybe I am taking the wrong aproach to the problem. If you are using Material2, you can use Angular Flex Layout for responsiveness. It compliments Angular2 well and is lightweight. Basically Material2 + Flex-layout is equivalent to Bootsrap library. Here's an example of how flex-layout can be used for grid system/responsiveness with Angular/Material2. Sample Code

Angular 4 & Material Stepper

ⅰ亾dé卋堺 提交于 2019-12-03 11:02:24
问题 Is it possible to reset (or just jump to the first step) inside of a stepper? It is not documented in the docs, but is it possible to do so? It is stated in the docs that the stepper is built on "CDK Stepper" (link?), but I can't find any examples which lead me to my goal. 回答1: Ok, it seems I found a solution (but it is not stated anywhere on the API). Add a reference to the stepper, then add ViewChild with the reference in your component typescript file. Create a method to change the index

How do you call closePanel in angular 4 autoComplete material

我与影子孤独终老i 提交于 2019-12-03 10:38:59
import { MdAutocomplete } from '@angular/material'; @Component({ template:' <input type="text" [mdAutocomplete]="auto"/> <md-autocomplete #auto="mdAutocomplete" #autoComplete> <md-option> Some Options </md-option> </md-autocomplete>' }) export class AutoComplete { @ViewChild('autoComplete') autoComplete: MdAutocomplete; closeAuto() { this.autoComplete.closePanel(); } } It is not the complete code but the idea is to call closePanel inside a method. closePanel is listed as a method on https://material.angular.io/components/autocomplete/api but it fails to work. It says method not found. tried

Change size of textarea

筅森魡賤 提交于 2019-12-03 09:33:53
I currently have a textarea like this: <textarea matInput rows="5" cols="40" placeholder="text"></textarea> However, it is always the same size. Any idea on how to change the size of the textarea ? Here's an example : <mat-form-field> <mat-label>Description</mat-label> <textarea matInput formControlName="description" matTextareaAutosize matAutosizeMinRows=1 matAutosizeMaxRows=5></textarea> </mat-form-field> Reference: https://material.angular.io/components/input/api Depending on what you've meant by: However, it is always the same size. There are two options. OPTION 1 (STATIC size depending on

Multiple autocomplete in same page with different source in angular 4 with angular material

时光毁灭记忆、已成空白 提交于 2019-12-03 08:44:21
问题 Multiple autocomplete in same page with different source in angular 4 with angular material: source :https://material.angular.io/components/autocomplete/examples I have followed the material autocomplete example and trying to add one more autocomplete in the same page but the source is different but not working. Is formcontrol is creating problem ?? import {Component} from '@angular/core'; import {FormControl} from '@angular/forms'; import 'rxjs/add/operator/startWith'; import 'rxjs/add