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>

相关推荐
一 乐1 天前
助农平台|基于SprinBoot+vue的助农服务系统(源码+数据库+文档)
前端·javascript·数据库·vue.js·ecmascript·springboot
vivo互联网技术1 天前
浅谈 AI 搜索前端打字机效果的实现方案演进
前端·vue·dom
●VON1 天前
Electron 小游戏实战:太空打砖块(Space Breakout)
前端·javascript·electron
重铸码农荣光1 天前
深入理解 JavaScript 原型机制:从“如何拿到小米 SU7”说起
前端·javascript
乐观的用户1 天前
搞懂虚拟列表实现原理与步骤
前端·vue.js
Heo1 天前
Webpack高级之常用配置项
前端·javascript·面试
Radan小哥1 天前
Docker学习笔记—day008
笔记·学习·docker
Mike_jia1 天前
DBSyncer:开源数据同步中间件全景实战指南
前端
源代码•宸1 天前
GoLang写一个简单版生命游戏模拟器
经验分享·笔记·学习·游戏·golang
烛阴1 天前
从`new`关键字开始:精通C#类与对象
前端·c#