
Angular自学笔记
angular资料真的少,认真学习,认真分享,请给我加个鸡腿!
优惠券已抵扣
余额抵扣
还需支付
¥9.90
¥99.00
购买须知?
本专栏为图文内容,最终完结不会低于15篇文章。
订阅专栏,享有专栏所有文章阅读权限。
本专栏为虚拟商品,基于网络商品和虚拟商品的性质和特征,专栏一经购买无正当理由不予退款,不支持升级,敬请谅解。
yusirxiaer
前端移动端一路の风景
展开
-
useEffect中使用异步函数
useEffect是不能直接用 async await 语法糖的原创 2022-06-18 20:52:01 · 1516 阅读 · 0 评论 -
Angular 内容投影 II
内容投影是一种模式,你可以在其中插入或投影要在另一个组件中使用的内容。简单来说,angular的内容投影就相当于vue的内容插槽slot。所有一下就能懂了。1、单插槽内容投影单插槽内容投影是指创建一个组件,你可以在其中投影一个组件。如果只有一个ng-content,不需要select属性。2、多插槽内容投影一个组件可以具有多个插槽。每个插槽可以指定一个 CSS 选择器,该选择器会决定将哪些内容放入该插槽。将select属性添加到<ng-content>元素。 Ang...原创 2021-12-06 00:40:41 · 292 阅读 · 0 评论 -
Angular自学笔记(?)依赖注入
什么是依赖注入依赖注入(DI)是一种设计模式, 也有相应的框架,比如InversifyJSAngular 有自己的 DI 框架, DI 框架会在实例化该类时向其提供这个类所声明的依赖项带修饰符的参数在ts中,一个类的参数如果带上修饰符,那个参数就变成了类的实例属性class Mobile { constructor(readonly name: string = '小米') {} logName() { console.log(this.name); }}上面的name原创 2021-02-17 22:19:51 · 170 阅读 · 0 评论 -
Angular自学笔记(?)生命周期
从实例化组件,渲染组件模板时,各声明周期就已开始ngOnChanges输入属性发生变化是触发,但组件内部改变输入属性是不会触发的import { Component, Input, OnInit, OnChanges } from '@angular/core';@Component({ selector: 'app-life-cycle', templateUrl: ` 点击按钮不会触发ngOnChanges <button (click)="title = '原创 2021-02-17 22:12:03 · 142 阅读 · 0 评论 -
Angular自学笔记(?)DI提供者
类提供者类提供者的创建和使用假设有logger类:import { Injectable } from '@angular/core';@Injectable()export class LoggerService { logs: string[] = []; constructor() { } log(message: string) { this.logs.push(message); console.log(message); }}类提供者,使用us原创 2021-02-17 22:01:23 · 230 阅读 · 0 评论 -
Angular自学笔记(?)结构型指令
内置指令的展开写法ngIfimport { Component } from '@angular/core';@Component({ selector: 'app-root', template: ` <button (click)="show = !show">toggle</button> <p *ngIf="show as aa">一段文字 {{ aa }}</p> <ng-template [ngIf]="sho原创 2021-02-16 21:28:28 · 135 阅读 · 0 评论 -
Angular自学笔记(?)属性型指令
基本概念用于改变DOM元素的外观或行为的指令组件是一种特殊的指令import {Component} from '@angular/core';@Component({ selector: 'app-root', template: ` <!--<app-for></app-for>--> <div app-for>dasfsada</div> `,})export class AppComponent {原创 2021-02-16 21:26:36 · 136 阅读 · 0 评论 -
Angular自学笔记(?)ContentChild和ContentChildren
ContentChild用法类似ViewChild, 获取投影中到组件或指令还有元素dom等获取投影中但组件import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';@Component({ selector: 'app-content-child-panel', templateUrl: './content-child-panel.component.html'})ex原创 2021-02-16 21:25:46 · 349 阅读 · 0 评论 -
Angular自学笔记(?)ViewChild和ViewChildren
ViewChild最好在ngAfterViewInit之后,获取模版上的内容获取普通domimport {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';@Component({ selector: 'app-view-child', template: ` <section> <h3>获取dom</h3>原创 2021-02-16 21:23:32 · 217 阅读 · 1 评论 -
Angular自学笔记(?)TemplateRef和ViewContainerRef
ElementRef由于ng是跨平台的为了减少视图层和渲染层的耦合也为了让ng更适应多平台,ng帮我们封装了ElementRef,我们可以通过ElementRef拿到native元素(在浏览器中也就是我们常说的DOM元素)下面我们看一段代码 import { Component, ElementRef, AfterViewInit } from '@angular/core'; @Component ({ selector:'my-app', t原创 2021-02-16 20:31:59 · 575 阅读 · 1 评论 -
Angular自学笔记(二)显示数据 绑定属性
显示数据1.显示数据ng的模版中,默认用双大括号{{}}绑定组件中的变量显示出来import { Component } from '@angular/core';@Component({ selector: 'app-root', template: ` <h1>{{title}}</h1> <h2>My favorite hero is: {{myHero}}</h2> `, styles: [`h1 { c原创 2021-02-16 20:24:35 · 197 阅读 · 0 评论 -
Angular自学笔记(一)ngModule 元数据
工作硬上开发angular项目,好难啊,上网搜资料教程真的贼少,吐槽真的没什么人用angular,自己学习到处搜集整理的笔记,分享出来,方便查看理解总结。应该适用于angular11系列(更新真快,反正我也不知道之前低版本不同 手动狗头)什么是angular module(ngModule)?angular module就是一个普通的类,但是这个类,一旦被@NgModule所装饰,那这个类就可以被称为angular module@NgModule元数据@NgModule 获取一个元数据对象,它会告原创 2021-02-16 19:06:32 · 344 阅读 · 0 评论 -
Angular rxjs Subject笔记
BehaviorSubject/* ehaviorSubject接受一个默认参数,相当于new Subject后自动next('aa') 之后到行为和Subject一致*/const behave = new BehaviorSubject('aa');behave.subscribe(res => { console.log(res); // aa bb});behave.next('bb');// 获取最新到值behave.getValue(); // 'bb'be原创 2021-02-16 18:48:46 · 247 阅读 · 0 评论 -
Angular rxjs operators 笔记
toArray/* toArray把结果都塞到数组里去*/const source = interval(1000);const example = source.pipe( take(10), toArray());example.subscribe(val => console.log(val));// output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]toArray/* pairwise把相邻的两个流组成数组*/原创 2021-02-16 15:54:33 · 486 阅读 · 0 评论 -
Angular CLI ng 指令指南
Angular CLI 使用教程指南参考Angular CLI 现在虽然可以正常使用但仍然处于测试阶段. Angular CLI 依赖 Node 4 和 NPM 3 或更高版本.安装要安装Angular CLI你需要先安装node和npm,然后运行以下命令来安装最新的Angular CLI:注意:Angular CLI 需要Node 4.X 和 NPM 3.X 以上原创 2018-01-25 13:05:41 · 2141 阅读 · 0 评论