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>

相关推荐
从零开始学习人工智能24 分钟前
快速搭建B/S架构HTML演示页:从工具选择到实战落地
前端·架构·html
虫虫rankourin1 小时前
在 create-react-app (CRA) 创建的应用中使用 react-router-dom v7以及懒加载的使用方法
前端·react.js
小刘鸭地下城1 小时前
Web安全必备:关键 HTTP 标头解析
前端
yddddddy1 小时前
html基本知识
前端·html
荣达2 小时前
koa洋葱模型理解
前端·后端·node.js
兔子不吃草~2 小时前
Transformer学习记录与CNN思考
学习·cnn·transformer
reembarkation2 小时前
使用pdfjs-dist 预览pdf,并添加文本层的实现
前端·javascript·pdf
KenXu3 小时前
F2C-PTD工具将需求快速转换为代码实践
前端
给月亮点灯|3 小时前
Vue3基础知识-setup()、ref()和reactive()
前端·javascript·vue.js
芜青3 小时前
【Vue2手录12】单文件组件SFC
前端·javascript·vue.js