小编ara*_*b78的帖子

默认情况下选中复选框角度材料

我正在尝试使用材质角度复选框,并将其默认设置为已选中,但它显示为未选中,有什么问题?

<mat-checkbox class = "example-margin" [(ngModel)] = obj.impresora> 
     <label>Printer</label> 
</mat-checkbox>
Run Code Online (Sandbox Code Playgroud)

obj.impresora属性是布尔值

checkbox angular-material angular-material2 angular

14
推荐指数
2
解决办法
6万
查看次数

重复动画角4

我创建了以下动画:

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"次.我怎么了?请帮忙

animation repeat angular angular-animations

7
推荐指数
1
解决办法
5001
查看次数

获取表单控件的名称

我正在使用角形的反应式表单,我需要将开始日期“开始日期”与结束日期“结束日期”进行比较,两个控件均在“ 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)

reactive-forms angular

5
推荐指数
2
解决办法
8100
查看次数

结构指令,位置工具提示

我创建了一个结构指令,它根据 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)

tooltip ng-template angular

3
推荐指数
1
解决办法
9144
查看次数

如何使用 Angular5 检查表单控件的更改

我使用反应式表单,我有多个输入,我想为三个输入显示一个错误,验证是;字段为必填字段,不得输入空格。

\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)

custom-validators angular angular-reactive-forms

2
推荐指数
1
解决办法
2万
查看次数

设置数字格式以将分数置于千位

我需要格式化一个数字以将点数放入数千个,我需要使用角度 2 中的管道对其进行格式化。Ejem:数字是 1983839,结果必须是 1.983.839 知道吗?

{{amount | number}}
Run Code Online (Sandbox Code Playgroud)

format pipe angular

1
推荐指数
1
解决办法
8699
查看次数

ng serve 的 Angular 项目错误找不到模块'@ angular-devkit / core'

我有 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)

visual-studio-code angular-cli angular

0
推荐指数
1
解决办法
322
查看次数