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

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Latest news
Latest news
J
Java Code Geeks
The Register - Security
The Register - Security
V
Visual Studio Blog
IT之家
IT之家
Martin Fowler
Martin Fowler
The GitHub Blog
The GitHub Blog
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Stack Overflow Blog
Stack Overflow Blog
The Cloudflare Blog
N
Netflix TechBlog - Medium
博客园 - 聂微东
D
Docker
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园_首页
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Check Point Blog
美团技术团队
爱范儿
爱范儿
A
About on SuperTechFans
Y
Y Combinator Blog
Engineering at Meta
Engineering at Meta
PCI Perspectives
PCI Perspectives
MyScale Blog
MyScale Blog
T
Threatpost
S
Securelist
量子位
C
Cyber Attacks, Cyber Crime and Cyber Security
Vercel News
Vercel News
宝玉的分享
宝玉的分享
Project Zero
Project Zero
S
Security @ Cisco Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Cisco Talos Blog
Cisco Talos Blog
罗磊的独立博客
M
MIT News - Artificial intelligence
雷峰网
雷峰网
G
Google Developers Blog
T
The Blog of Author Tim Ferriss
Google Online Security Blog
Google Online Security Blog
The Last Watchdog
The Last Watchdog
P
Proofpoint News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
Schneier on Security
Schneier on Security
H
Hacker News: Front Page
T
Troy Hunt's Blog
U
Unit 42
Scott Helme
Scott Helme

博客园 - 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

demo02_lianxi

demo03_for

demo04_lianxi

demo05_directive

demo06_custom_directive

demo07_communication

xiaotou

datou

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

通过服务来实现通信:

父组件

子组件

demo08_lianxi

聊天室、用户

聊天室

用户

demo09_bind

test.css

demo10_lianxi

demo11_pipe

sex.pipe.ts

test.pipe.ts

demo12_service

user.service.ts

heartbeat.service.ts

demo13_http

myhttp.service.ts

demo14_lianxi

storehttp.service.ts