惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - kunyashaw

基于langgraph的智能问答工作流 langgraph 基础使用(条件/循环/嵌套子图) vue3Crush以及对比vue2 渗透与常见服务配置 LangChain教程-4、构建简易智能 PPT 生成器 LangChain教程-3、Langchain进阶 LangChain教程-2、Langchain基础 LangChain教程-1、python基础 openclaw skill--一键生成项目宣讲介绍网页及长截图 openclaw新手skill推荐: openclaw-newbie-faq 用opencode和minimax给娃搭了一个raz学习站点 clawdbot(新名字:moltbot、OpenClaw)折腾过程 node基础 vue基础 某业务技术架构 漏洞治理 堡垒机方案 linux常见软件的环境搭建 linux运维基础
angualr基础
kunyashaw · 2023-06-26 · via 博客园 - kunyashaw

一、Angular概述

基于命令行的开发方式?
①hot reload
②编译工作
③集成了webpack打包工具
。。。。


angular.cn 中文
angular.io 正式官网
angular.cn/guide/styleguide 风格指南

1、what?
angular是一个Google推出的js框架,是以模块为基本单位,模块又可以包含组件、指令、过滤器。。

1.1 版本问题
angular angular2.0以后所有的版本统称为angular
(当前学习ng4.0)

angular.js angular1.* 统称为angular.js
(http://www.runoob.com/angularjs/angularjs-tutorial.html)

1.2 版本之间的区别
①新版本是有组件的概念的
②老版本是$scope和controller为主
③angular引入了rxjs
④angular采用ts(typescript是es6的超集,是由微软和谷歌) ts是一种强类型检查机制的语言
⑤angular可读性、提高了代码的复用率、维护成本变低。。。

2、where
可以使用支持angular的Ionic框架来实现移动端的开发,直接使用angular来实现pc端的开发

实现操作比较频繁的SPA

3、why
①遵循w3c所推出的webComponent标准(组件化)
②代码具有更好的可读性和可维护性、
③引入了更多的高效率的工具 ,比如rxjs\immutable.js。。。, 让代码的编译、部署更简单
④ts --》 健壮

4、how
用 Angular 扩展语法编写 HTML 模板,
用组件类管理这些模板,
用服务添加应用逻辑,
用模块打包发布组件与服务。

angular的开发整体框架,是有8大组成部分构成:
①组件:定义视图

②服务:将经常用到的数据和方法封装在一个类中;这能让你的代码更加模块化、可复用,而且高效

③依赖注入(DI): 服务的元数据提供了一些信息,Angular 要用这些信息来让组件可以通过使用该服务

④装饰器:用来描述当前这个类是一个什么样的类 @Component @NgModule @Pipe @Directive @Injectable

⑤模板:普通的 HTML 和指令与绑定标记(markup)组合起来

⑥指令:模板中的指令会提供程序逻辑
循环、条件判断。。。

⑦数据绑定:绑定标记会把你应用中的数据和 DOM 连接在一起。
①事件绑定让你的应用可以通过更新应用的数据来响应目标环境下的用户输入。
②属性绑定让你将从应用数据中计算出来的值插入到 HTML 中。
③双向数据绑定

⑧管道:转换要显示的值以增强用户体验

搭建环境的方式:
方式1:
①下载quickstart-master.zip压缩包
https://github.com/angular/quickstart download
或者 直接拷贝老师提供的压缩包
②解压缩 压缩包,进入对应的目录中
执行npm install 安装项目所需要用到的依赖
③npm start 启动开发服务器

方式2:
Angular CLI是一个命令行界面工具,它可以创建项目、添加文件以及执行一大堆开发任务,比如测试、打包和发布。
//安装基于angular的命令工具
npm install -g @angular/cli
//创建一个有着ng模板的项目
ng new my-app
//进入当前目录下的my-app
cd my-app
//启动开发服务器
ng serve --open

①创建文件 app/test/test.component.ts

        ②将类装饰成一个组件类

            import {Component} from '@angular/core'

            @Component({

                selector:'test',

                template:`<h1>it is a test</h1>`

            })

            export class Demo01Component{

            }

        ③使用组件

            ①到模块中声明

                app.module.ts中,

                import {TestComponent} from './test/test.component'

                @NgModule({

                    declarations:[TestComponent]

                })

            ②<test></test>

demo01

<wiz_code_mirror>

demo02_lianxi

<wiz_code_mirror>

demo03_for

<wiz_code_mirror>

demo04_lianxi

<wiz_code_mirror>

demo05_directive

<wiz_code_mirror>

<wiz_code_mirror>

demo06_custom_directive

<wiz_code_mirror>

<wiz_code_mirror>

demo07_communication

xiaotou

<wiz_code_mirror>

datou

<wiz_code_mirror>

通过ViewChild来实现类似ref的效果:

<wiz_code_mirror>

通过服务来实现通信:

父组件

<wiz_code_mirror>

子组件

<wiz_code_mirror>

demo08_lianxi

聊天室、用户

聊天室

<wiz_code_mirror>

用户

<wiz_code_mirror>

demo09_bind

<wiz_code_mirror>

test.css

<wiz_code_mirror>

demo10_lianxi

<wiz_code_mirror>

demo11_pipe

<wiz_code_mirror>

<wiz_code_mirror>

sex.pipe.ts

<wiz_code_mirror>

test.pipe.ts

<wiz_code_mirror>

demo12_service

<wiz_code_mirror>

user.service.ts

<wiz_code_mirror>

heartbeat.service.ts

<wiz_code_mirror>

demo13_http

<wiz_code_mirror>

myhttp.service.ts

<wiz_code_mirror>

demo14_lianxi

<wiz_code_mirror>

storehttp.service.ts

<wiz_code_mirror>