angular常用引入

需要自己引入的


1. http请求

import { HttpClient, HttpHeaders } from '@angular/common/http'; 

2. 路由参数获取

import { ActivatedRoute } from '@angular/router'; 

用法

const id = +this.route.snapshot.paramMap.get("id"); //route.snapshot 是组件创建后的url快照,使用这个是为了避免js修改url后获取参数错误

3. 跳转

import { Location } from '@angular/common'; 

4.组件接收参数

import { Component, OnInit ,Input } from '@angular/core';

用法

@Input() bookName : string;

5.http异常

import { catchError, map, tap } from 'rxjs/operators';

自动构建会生成的


1. 依赖注入

import { Injectable } from '@angular/core';

2. 生命周期 OnInit

import { Component, OnInit } from '@angular/core';

你可能感兴趣的:(angular常用引入)