有没有办法使用 删除nestjs monorepo 中的特定应用程序nest/cli?我在文档和开发论坛中找不到它。
如何在组件中调用角度材质侧导航操作?我有一个用例,sidenav 仅在方法触发时才能打开/关闭callMethods()。我也不能简单地传递open(e)(callMethods()需要 1 个参数)。有办法实现这个目标吗?
应用程序.html
<mat-sidenav-container class="example-container">
<mat-sidenav #sidenav [mode]="mode.value">
<p>
some nav here
</p>
</mat-sidenav>
<mat-sidenav-content>
<p><button mat-button (click)="open(sidenav)">Toggle</button></p>
<p>
some text here
</p>
</mat-sidenav-content>
</mat-sidenav-container>
Run Code Online (Sandbox Code Playgroud)
应用程序.ts
open(e: any) {
e.toggle();
}
callMethods() {
this.open(); // required 1 arguments
this.otherMethod();
}
anotherMethod() {
this.open(); // required 1 arguments
this.otherMethod();
}
Run Code Online (Sandbox Code Playgroud)
注:我注意到有一个帖子,但不清楚
如何将required验证器设置为可选是反应形式。我有两个输入amount和volume. 如果用户选择amount单选按钮,则必须从输入中删除所需的验证volume。如果volume,必须从amount
应用程序.html
<form #recForm="ngForm" name="form" [formGroup]="form" (ngSubmit)="onSubmit()">
<div>
<div class="label">
<mat-label>Charged by</mat-label>
</div>
<mat-radio-group (change)="onChargesType($event)">
<mat-radio-button
*ngFor="let charges of chargedBy; let i = index"
[checked]="i === 0"
[value]="charges"
>{{ charges }}</mat-radio-button
>
</mat-radio-group>
</div>
<mat-form-field *ngIf="!isAmount">
<input formControlName="volume" matInput placeholder="Volume" />
</mat-form-field>
<mat-form-field *ngIf="isAmount">
<input formControlName="amount" matInput placeholder="Amount" />
</mat-form-field>
</form>
Run Code Online (Sandbox Code Playgroud)
应用程序
chargedBy: string[] = ['amount', 'volume'];
ngOnInit() {
this.isChargedByAmount = true;
this.form = this.fb.group({ …Run Code Online (Sandbox Code Playgroud) angular-material angular angular-reactive-forms angular-validator
我正在尝试在角度材料上实现全选复选框。当用户单击特定复选框(项目)时,主复选框应显示不确定,如果所有复选框都被选中,则变为选中状态。目前我有一些奇怪的行为。谁能让我知道我哪里出错了?这是stackblitz。这是我的示例代码:
应用程序.html
<fieldset class="demo-fieldset">
<div>
<mat-checkbox aria-label="Select All" [checked]="isChecked(selected3, itemsObject)" [indeterminate]="isIndeterminate(selected3, itemsObject)" (click)="toggleAll(selected3, itemsObject)">
Select All list of user (Array of objects) {{isChecked(selected3, itemsObject)}}
</mat-checkbox>
</div>
<div class="demo-select-all-checkboxes" *ngFor="let item of itemsObject">
<mat-checkbox [checked]="exists(item, selected3)" (click)="toggle(item, selected3)">
{{ item.val }}
</mat-checkbox>
{{exists(item, selected3)}}
</div>
</fieldset>Run Code Online (Sandbox Code Playgroud)
应用程序
import {
Component
} from '@angular/core';
@Component({
selector: 'app',
templateUrl: 'app.html',
styleUrls: ['app.css'],
})
export class CheckboxConfigurableExample {
itemsObject = [{
id: 1,
val: 'john'
}, {
id: …Run Code Online (Sandbox Code Playgroud)这里我有两个容器,第一个容器假设显示 json 中是否存在值,第二个容器显示 json 中的值是否为空。这是我的代码:
应用程序组件.html
<!-- show this container if value is exist -->
<ng-container *ngIf="outletName">
<div class="media media-xs align-items-center mb-5">
<div class="media-right float-right">
<a class="drop-assigned-outlet" href="#"><i class="fa fa-trash-o"></i></a>
</div>
<button class="btn btn-primary-ln" *ngIf="outletName">Change assigned outlet</button>x
</div>
</ng-container>
<!-- show this container if value is empty -->
<ng-container *ngIf="outletName == ''">
<div class="media media-xs align-items-center mb-5">
<p>No outlet have assigned</p>
</div>
<button class="btn btn-primary-ln">Assign an outlet</button>
</ng-container>
Run Code Online (Sandbox Code Playgroud)
数据.json
[
{
"staffId": "59998eeadfb23a8c0bba5769",
"staffName": "Sutton Fitzpatrick",
"outletName": "Marjorie Fitzgerald",
"outletId": …Run Code Online (Sandbox Code Playgroud)