我正在使用角度材料6,我在mat-form-field mat-error中显示错误,当在mat-form-field之后移动到正确显示的mat-error时.
不工作代码:
<mat-form-field>
<input matInput type="time" formControlName="ToTime"/> <mat-error *ngIf="DaterForm.get('ToTime').hasError('InValidToTime')">FromTime Should be less than ToTime if choose a same date</mat-error>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)
工作正常:
<input matInput type="time" formControlName="ToTime"/> </mat-form-field>
<mat-error *ngIf="DaterForm.get('ToTime').hasError('InValidToTime')">FromTime Should be less than ToTime if choose a same date</mat-error>
Run Code Online (Sandbox Code Playgroud)
有人解释了为什么不在该控制范围内工作.
现场演示: stackblitz
我mat-autocomplete在我的 Angular 应用程序下使用小部件:
<mat-form-field class="col-md-3" color="warn">
<input type="text"
id="libelleShop"
#inputSelectShop
placeholder="Selectionner la boutique"
matInput
formControlName="libelleShop"
ngDefaultControl
[matAutocomplete]="auto">
<mat-autocomplete #auto="matAutocomplete""
(optionSelected)="onShopSelectionChanged($event)">
<mat-option *ngFor="let shop of shopData" [value]="shop.value">
{{shop.name}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)
我的商店数据是这样的:
shopData = [
{name: 'AAA' , value :'11'},
{name: 'BBB', value :'22'},
{name: 'CCC', value : '33'}
];
Run Code Online (Sandbox Code Playgroud)
这样的-选项被显示name,但在选择由输入displaysitvalue不是name。
知道我需要其他治疗的价值,我不会改变[value]的mat-automplete。
我如何将名称引用到输入中?
建议??
angular-material angular-material2 angular angular-material-6
我有一个带有 ngfor 的 mat-accordion,当您单击面板时,会显示一个表格。
除了垫排序之外,一切都按预期工作,它只对第一个表进行排序。
我读到我需要将模板引用变量放在每个表中,但我如何动态地做到这一点?或者有其他一些方法来实现这一点。
这是我的代码:
<mat-accordion style="width: 80%">
<mat-expansion-panel *ngFor="let customer of customers; let i = index" (opened)="openPanel(customer);">
<mat-expansion-panel-header>
<mat-panel-title>
{{customer.name}}
</mat-panel-title>
<mat-panel-description>
<span style="text-align:center">{{" Active Calls: " + customer.active}}</span>
<span style="margin-left: 100px;">{{" Talking Calls: " + customer.talking}}</span>
</mat-panel-description>
</mat-expansion-panel-header>
<table #HERE-I-NEED-TO-PUT-DYNMIC-ID mat-table [dataSource]="dataSource" matSort class="mat-elevation-z8">
<ng-container *ngFor="let column of tableColumns;" matColumnDef="{{column.field}}">
<th mat-header-cell *matHeaderCellDef mat-sort-header> {{column.name}} </th>
<td mat-cell *matCellDef="let element">
<span *ngIf="column.field !== 'answered'"> {{element[column.field]}} </span>
<span *ngIf="column.field === 'answered' && element[column.field] > 0">{{getTime(element[column.field] * 1000) …Run Code Online (Sandbox Code Playgroud) 在关闭材质对话框之前,如何使用beforeClose()方法显示确认消息?
this.dialogRef.beforeClose().subscribe(result => {
var cn = confirm('You have begun editing fields for this user.
Do you want to leave without finishing?')
console.log(cn);
})
Run Code Online (Sandbox Code Playgroud) angular-material angular-material2 angular angular-material-6
我正在尝试减小 mat-select 下拉面板的默认大小,但无法弄清楚如何去做
我试过给 width ,试过在 angular mat-select 中覆盖面板类,但尺寸似乎没有减小
我的模板文件
<div class="col-md-8">
<mat-form-field style="float: right">
<mat-select panelclass="my-panel" placeholder="Select Course"(selectionChange)="selectCourse($event,courses)" disableOptionCentering>
<mat-option *ngFor="let course of courses" [value]="course.courseId">
{{course.courseCode}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
Run Code Online (Sandbox Code Playgroud)
我的 CSS 文件
.my-panel {
background: orange;
height: 300px;
display: flex;
flex-direction: column;
justify-content: space-between;
min-width: 350px !important;
}
Run Code Online (Sandbox Code Playgroud)
Please tell me how I can solve the following problem:\nI need to implement a dynamically created menu with different nesting levels depending on the data model object. At the moment, using recursion, we managed to create the menu as such, however, there is a problem of assigning the attribute [matMenuTriggerFor] for, directly, the submenu. The problem is that all subsequent submenus in fact refer to the very first, so when you hover over any of the submenus, it causes a …
组件: https: //material.angular.io/components/snack-bar/examples
我有一个页面是父部分('#wrapper_container')。我想在“#wrapper_element”的子元素的中心弹出小吃栏。
谢谢
我有一个垫子扩展面板,我想将其扩展到它下方的元素上,而不是简单地向下移动该元素。我尝试调整 mat-expansion 元素的 z-index 但这不起作用。我在 angular material docs/github 中没有看到任何表明可以这样做的内容。有没有人这样做过或知道如何实现?
任何帮助/提示/建议将不胜感激。
更新: 我想要的解决方案应该与此类似。它可以包含多个元素(垫子选择、日期选择器等。)
我有一个数据集,正在角度材料表中显示(使用角度 6)。已按照此文档链接执行此操作。我一直在寻找一种优化/简洁的方法来将行表示为列,将列表示为行
这是我的html:
<table mat-table [dataSource]="subscriptionPlans" class="mat-elevation-z8 subscription-table text-left">
<ng-container matColumnDef="subscription">
<th mat-header-cell *matHeaderCellDef> Subscription </th>
<td mat-cell *matCellDef="let element"> {{element.name}} </td>
</ng-container>
<ng-container matColumnDef="rows">
<th mat-header-cell *matHeaderCellDef> Rows in million </th>
<td mat-cell *matCellDef="let element"> {{(element.rowsInMillion) ? element.rowsInMillion : 'custom'}} </td>
</ng-container>
<ng-container matColumnDef="price">
<th mat-header-cell *matHeaderCellDef> Pricing </th>
<td mat-cell *matCellDef="let element"> {{(element.price) ? element.price : 'custom'}} </td>
</ng-container>
<ng-container matColumnDef="additionalPricing">
<th mat-header-cell *matHeaderCellDef> Pricing for additional 1 million rows </th>
<td mat-cell *matCellDef="let element"> {{(element.extraPerMillion) …Run Code Online (Sandbox Code Playgroud) 我试图在用户展开节点时动态加载子节点。
问题是当我填充子数组时,mat-tree 不显示子数组。如果我使用简单的 *ngFor 显示相同的数据,当子数组添加了元素时,它会显示它们。
我这里有一个工作示例:stackblitz example 这是代码和html
ts
import {NestedTreeControl} from '@angular/cdk/tree';
import {Component} from '@angular/core';
import {MatTreeNestedDataSource} from '@angular/material/tree';
export class PropertyLevel {
constructor(
public code : string,
public hasSubLevels: boolean,
public subproperties : PropertyLevel[]
){}
}
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
name = 'Angular';
nestedTreeControl: NestedTreeControl<PropertyLevel>;
nestedDataSource: MatTreeNestedDataSource<PropertyLevel>;
constructor() {
this.nestedTreeControl = new NestedTreeControl<PropertyLevel>(this._getChildren);
this.nestedDataSource = new MatTreeNestedDataSource();
this.nestedDataSource.data = [
new PropertyLevel( '123', false, []),
new …Run Code Online (Sandbox Code Playgroud)