模块,组件,指令如何注册

@NgModule 元数据

NgModule 是一个带有 @NgModule() 装饰器的类。@NgModule() 装饰器是一个函数,它接受一个元数据对象,该对象的属性用来描述这个模块。其中最重要的属性如下。

declarations(可声明对象表) —— 那些属于本 NgModule 的组件、指令、管道。

exports(导出表) —— 那些能在其它模块的组件模板中使用的可声明对象的子集。

imports(导入表) —— 那些导出了本模块中的组件模板所需的类的其它模块。

providers —— 本模块向全局服务中贡献的那些服务的创建器。 这些服务能被本应用中的任何部分使用。(你也可以在组件级别指定服务提供者,这通常是首选方式。)

bootstrap —— 应用的主视图,称为根组件。它是应用中所有其它视图的宿主。只有根模块才应该设置这个 bootstrap 属性。

import { NgModule } from "@angular/core";
import { CommonModule } from "@angular/common";
import { TestComponent } from "./test/test.component";
import { TestRoutingModule } from "./test-routing.module";
import { TabModule } from "@xxxxx";

@NgModule({
declarations: [TestComponent],
imports: [CommonModule, TestRoutingModule , TabModule],
})
export class ChartsModule {}

ERROR TypeError: Cannot read property ‘nativeElement’ of undefined

这里就需要特别的注意 angular 的生命周期了,需要知道 DOM 在什么时候挂载,就是 ngAfterViewInit

Can’t bind to ‘ngModel’ since it isn’t a known property of ‘ti-date’

import { FormsModule } from '@angular/forms';

@NgModule({
imports: [
FormsModule
]
})

angular 如何格式化日期


ncaught (in promise): NullInjectorError: R3InjectorError(ChartsModule)[DatePipe -> DatePipe -> DatePipe -> DatePipe]: NullInjectorError: No provider for DatePipe!

ERROR Error: InvalidPipeArgument: ‘The minimum number of digits after fraction (2) is higher than the maximum (1).’ for pipe ‘DecimalPipe’

angular 如何处理数据小数点保留一位

接收的参数格式为{最少整数位数}.{最少小数位数}-{最多小数位数}

如何切换分支

查看分支:git branch -a, git branch git pull

切换分支: git checkout 分支名字

git status 查看状态

git add 添加修改文件

git commit 提交本地仓库

git push 提交到远程仓库

提交 mr 提交合并请求

解决浏览器 resize

git commit 中文乱码

git config --global i18n.commitencoding utf-8

angular 表单验证

https://www.jianshu.com/p/6f511c5fefe5

ERROR Error: There is no FormControl instance attached to form control element with name: ‘urlTimeControl’

创建表单控制器

从 @angular/forms 导入 FormBuilder, FormControl, FormGroup

注入 private formBuilder: FormBuilder

public menuConfigForm: FormGroup;

new FormControl()

formGroup 有 removeControl, addControl, get, reset,

监听路由变化

Angular8 中 监听url变化

如何 rebase git 冲突

别人和我改动的代码相同,但是别人先合进主分支

git checkout 主分支

git pull 更新主分支最新代码

git checkout 自己的分支

git rebase 主分支

解决冲突,git add 冲突的文件,git rebase --continue

git commit -m""

git push