随笔分类 -  Angular学习

摘要:<!-- 父组件 father.html --> <div class="father"> <dwb-child></dwb-child> </div> <div class="other"> <dwb-child></dwb-child> </div> <!-- 子组件 child.html -- 阅读全文

posted @ 2021-02-03 14:41 !sylar 阅读(811) 评论(1) 推荐(0) 编辑

摘要://global.service.ts import { Injectable } from "@angular/core" import { Subject } from "rxjs" interface globalModalModel { tipMsg?: string show?: bool 阅读全文

posted @ 2020-10-29 17:15 !sylar 阅读(620) 评论(0) 推荐(0) 编辑

摘要:长久以来,使用moment.js时,都很纠结。 确实很好用,但是占用的包体积却很大。其中主要有一堆用不到的locale。经过搜寻收,找到了解决办法: 1.在src文件夹下创建一个locale空的文件夹 2.在angular.json 的 fileReplacements 内新增下面设定: { "re 阅读全文

posted @ 2020-10-29 11:55 !sylar 阅读(262) 评论(0) 推荐(0) 编辑

摘要:this.router.navigate(['action-selection'], { state: { example: 'bar' } }); 路由跳转,传入参数。 在目标页面接收参数: 此处需要注意(必须在constructor中获取传参,当从其他地方跳转进页面时,如果没有传参会引起报错。所 阅读全文

posted @ 2020-08-11 18:14 !sylar 阅读(508) 评论(0) 推荐(0) 编辑

摘要:表单初始数据: this.deviceForm = this.fb.group({ name: ["", [Validators.required]], serialNumber: [""], modelname: [""], // 设备型号 model: [""], // 型号 modelId: 阅读全文

posted @ 2020-07-28 09:59 !sylar 阅读(830) 评论(0) 推荐(0) 编辑

摘要:this.validateForm.reset() for (const key in this.validateForm.controls) { this.validateForm.controls[key].markAsPristine() this.validateForm.controls[ 阅读全文

posted @ 2020-07-01 16:17 !sylar 阅读(1496) 评论(0) 推荐(0) 编辑

摘要:import { Directive, Input, OnChanges, SimpleChanges } from '@angular/core'; import { AbstractControl, NG_VALIDATORS, Validator, ValidatorFn, Validator 阅读全文

posted @ 2020-06-22 15:57 !sylar 阅读(208) 评论(0) 推荐(0) 编辑

摘要:使用 patchValue() 方法会比使用 setValue() 方法更好! 1、patchValue() // angular2/packages/forms/src/model.ts export class FormGroup extends AbstractControl { ... pa 阅读全文

posted @ 2020-06-19 15:01 !sylar 阅读(3344) 评论(0) 推荐(0) 编辑

摘要:父子组件数据传递 父级向子级传递对象: @Input 例如:一个下拉框的列表数据 options 来自父组件。 子组件代码: import { Component, Input } from '@angular/core'; @Input() options: Array<string>; 在子组件 阅读全文

posted @ 2020-06-03 17:29 !sylar 阅读(860) 评论(0) 推荐(0) 编辑

摘要:1.首先我们看一下 *ngIf的用法 <div *ngIf="display"> hello world </div> 在display为true 的时候,会显示 hello world,如果想要在为false的时候展现另一个内容的时候时候呢? <div *ngIf="!display"> worl 阅读全文

posted @ 2020-05-13 13:51 !sylar 阅读(1737) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示