angular hero学习

install node
https://nodejs.org

C:\xxx\Downloads\node-v20.10.0-x64

C:\Program Files\nodejs\

C:\angular>node -v

v20.10.0

C:\angular>npm -v

10.2.3

install angualr

npm install -g @angular/cli

error

设置淘宝源

npm config set registry https://registry.npm.taobao.org

npm config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass

恢复默认源

npm config delete registry

npm config delete sass_binary_site

C:\angular>npm install -g @angular/cli

added 227 packages in 16s

npm notice

npm notice New patch version of npm available! 10.2.3 -> 10.2.5

npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.2.5

npm notice Run npm install -g npm@10.2.5 to update!

npm notice

ng new angular-tour-of-heroes --no-standalone --routing --ssr=false

cd angular-tour-of-heroes

ng serve --open

修改显示:

title = 'Tour of Heroes';

双花括号语法是 Angular 的插值绑定语法

<h1>{{title}} </h1>

打开 src/styles.css 并把下列代码添加到此文件中。

创建新组件

ng generate component heroes

C:\angular\angular-tour-of-heroes>ng generate component heroes

CREATE src/app/heroes/heroes.component.html (21 bytes)

CREATE src/app/heroes/heroes.component.spec.ts (601 bytes)

CREATE src/app/heroes/heroes.component.ts (199 bytes)

CREATE src/app/heroes/heroes.component.css (0 bytes)

UPDATE src/app/app.module.ts (475 bytes)

hero = 'Windstorm';

接口类:
export interface Hero {

id: number;

name: string;

}

管道

<h2>{{hero.name | uppercase}} Details</h2>

双向绑定

<div>

<label for="name">Hero name: </label>

<input id="name" (ngModel)="hero.name" placeholder="name">

</div>

相关推荐
计算机魔术师3 分钟前
谷歌搜索广告踩刹车,AI广告成为救命稻草
前端
总要学点什么10 分钟前
第81篇:数据可视化-PM2.5分布——让圆点的胖瘦替每座城市报出浓度
前端·信息可视化·echarts·cesium·空间分析
IT_陈寒11 分钟前
Vue的v-for里用了个临时变量,页面直接挂了
前端·人工智能·后端
hunter_07621 分钟前
一次 iOS 真机签名 409 的完整排查:证书、设备、描述文件为什么总是"对不上"
前端
枣把儿28 分钟前
开源!公众号排版+一键发布工具懒人版
前端
2501_9160074733 分钟前
抓包工具功能对比,TraceEagle、Charles、Fiddler、Wireshark、mitmproxy 差别
前端·网络协议·ios·adb·https·fiddler·wireshark
Flynt37 分钟前
AI 写的页面一眼假?有人把"假指纹"写成 62 条规则,不用大模型就能跑
前端·ai编程·claude
kyriewen41 分钟前
我把 10 道面试题答案真跑了一遍:6 道是错的
前端·javascript·面试
每天题库1 小时前
西藏安全员 A 证备考真题题库 强化重点知识刷题提升通过率
学习·安全·考试·题库·考证
Be for thing1 小时前
PyTorch基础|Tensor张量详解,张量创建、数据类型与常用操作
pytorch·学习·1024程序员节