我正在尝试使用材质角度复选框,并将其默认设置为已选中,但它显示为未选中,有什么问题?
<mat-checkbox class = "example-margin" [(ngModel)] = obj.impresora>
<label>Printer</label>
</mat-checkbox>
Run Code Online (Sandbox Code Playgroud)
obj.impresora属性是布尔值
我创建了以下动画:
fade.animation.ts:
import { Component } from '@angular/core';
import { trigger, state, animate, query, transition, style, stagger } from
'@angular/animations';
export let fade = trigger('fade', [
state('void', style({ opacity: 0 })),
transition(':enter, :leave', [
animate(2000)
])
]);
Run Code Online (Sandbox Code Playgroud)
我正在使用下一个组件:
<div id="mpl_loader" class="divCabeceraTitulo">
<div class="lineaTitulo">
<div class="logoMinisterio" [@fade]>
<img src="assets/imagenes/SRDLOGO.png">
</div>
<div class="logoGesRepro">
<img class="imgGesRepro" src="assets/imagenes/gesReproB.png">
</div>
<div class="descripcionAplicacion">
<span>título</span>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
动画工作,问题是它只运行一次,当它加载组件时,我想要的是它"n"次.我怎么了?请帮忙
我正在使用角形的反应式表单,我需要将开始日期“开始日期”与结束日期“结束日期”进行比较,两个控件均在“ dateLessThan”函数中进行了验证,但是问题是我不知道如何要求控制权正在评估
//Some stuff
public fechaInicio = new FormControl('', [
Validators.required
, this.dateLessThanTo
]);
public fechaFin = new FormControl('', [
Validators.required
, this.dateLessThan
]);
createForm() {
this.contratoForm = this.formBuilder.group({
fechas: this.formBuilder.group({
fechaInicio: this.fechaInicio,
fechaFin: this.fechaFin
}, { validator: this.dateLessThan('fechaInicio', 'fechaFin') }),
});
}
Run Code Online (Sandbox Code Playgroud)
在这里,我需要知道比较日期的控件名称:
dateLessThanTo(fieldControl: FormControl) {
//
//if (fechaInicio.value > FechaFin.value){
// return true;
//}
//else{
// return false;
// }
}
//Some stuff
Run Code Online (Sandbox Code Playgroud) 我创建了一个结构指令,它根据 ng-template 中的内容显示工具提示,当我将鼠标悬停在文本“查看工具提示”上时,工具提示显示正确,但它显示在顶部:0px left: 0px position of在屏幕上,我希望它显示在文本“查看工具提示”的正上方,我已经使用“getBoundingClientRect()”方法实现了 elementRef 的尺寸,但我不知道如何在工具提示中应用它们。任何的想法?
tooltip.directive.ts
import { Component, Input, HostListener, Directive, ElementRef,
TemplateRef, ViewContainerRef, ContentChild, ComponentRef } from
'@angular/core';
@Directive({ selector: '[tooltipDirective]' })
export class TooltipDirective {
private tooltipId: string;
private dimensiones:{};
constructor(private elementRef: ElementRef,
private viewContainerRef: ViewContainerRef) { }
@Input() parametroPlantilla: TemplateRef<any>;
@ContentChild( "tooltipTemplate" ) private tooltipTemplateRef: TemplateRef
<Object>;
@HostListener('mouseenter') onMouseEnter(): void {
this.viewContainerRef.createEmbeddedView(this.tooltipTemplateRef);
this.dimensiones = this.elementRef.nativeElement.getBoundingClientRect();
}
@HostListener('mouseleave') onMouseLeave(): void {
if (this.viewContainerRef) {
this.viewContainerRef.clear();
}
}
}
Run Code Online (Sandbox Code Playgroud)
display.component.ts
...Some stuff
<div tooltipDirective>See …Run Code Online (Sandbox Code Playgroud) 我使用反应式表单,我有多个输入,我想为三个输入显示一个错误,验证是;字段为必填字段,不得输入空格。
\n\n组件.html:
\n\n <form [formGroup]="contratoForm" class="campo-form">\n <div class="campoFormulario">\n <label class="etiquetaFormulario" for="txtCodigoContrato">C\xc3\xb3digo contrato</label>\n <div style="display:inline-block; position: relative;" class="control">\n <input [formControl]="txtCodigoContrato" type="text" id="txtCodigoContrato" name="txtCodigoContrato" class="cajaTexto ancho80" />\n <span>/</span>\n </div> \n <div style="display:inline-block; position: relative;" class="control"> \n <input [formControl]="txtCodigoContrato2" type="text" id="txtCodigoContrato2" name="txtCodigoContrato2" class="cajaTexto ancho80" /> \n </div>\n </div>\n <div class="campoFormulario">\n <label class="etiquetaFormulario" for="txtContrato">Contrato</label>\n <div style="display:inline-block; position: relative;" class="control">\n <input [formControl]="txtContrato" type="text" id="txtContrato" name="txtContrato" class="cajaTexto ancho350" />\n\n </div>\n </div>\n <div *ngIf="((!txtCodigoContrato.valid && (txtCodigoContrato.dirty || txtCodigoContrato.touched)) && (txtCodigoContrato.hasError(\'required\') || txtCodigoContrato.hasError(\'hasWhites\')))\n ||\n ((!txtCodigoContrato2.valid && (txtCodigoContrato2.dirty …Run Code Online (Sandbox Code Playgroud) 我需要格式化一个数字以将点数放入数千个,我需要使用角度 2 中的管道对其进行格式化。Ejem:数字是 1983839,结果必须是 1.983.839 知道吗?
{{amount | number}}
Run Code Online (Sandbox Code Playgroud) 我有 angular/cli 的全球版本 1.5.0,我已经下载了 Visual Studio 代码,并使用命令“ng new projectCheckBox”创建了一个项目,然后我做了一个 ng serve 并且 Visual Studio 代码向我抛出以下内容错误
E: \ Projects \ AngularCode \ projectCheckBox> ng serve
module.js: 487
throw err;
^
Error: Cannot find module '@ angular-devkit / core'
at Function.Module._resolveFilename (module.js: 485: 15)
at Function.Module._load (module.js: 437: 25)
at Module.require (module.js: 513: 17)
at require (internal / module.js: 11:18)
at Object. <anonymous> (E: \ Projects \ AngularCode \ projectCheckBox \ node_modules \ @ angular-devkit \ schematics \ src \ tree \ …Run Code Online (Sandbox Code Playgroud) angular ×7
angular-cli ×1
animation ×1
checkbox ×1
format ×1
ng-template ×1
pipe ×1
repeat ×1
tooltip ×1