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 [email protected] 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>

相关推荐
梦幻通灵2 分钟前
Excel分组计算求和的两种实现方案
前端·excel
柴薪之王、睥睨众生8 分钟前
(自用)Java学习-5.12(Redis,B2C电商)
java·开发语言·学习
whatever who cares39 分钟前
CSS3 伪类和使用场景
前端·css·css3
水银嘻嘻1 小时前
Web 自动化之 HTML & JavaScript 详解
前端·自动化·html
天天打码1 小时前
Lynx-字节跳动跨平台框架多端兼容Android, iOS, Web 原生渲染
android·前端·javascript·ios
LVerrrr1 小时前
Missashe考研日记-day36(改版说明)
学习·考研
大G哥1 小时前
项目中利用webpack的require.context实现批量引入/导入图片
前端·webpack·node.js
虾球xz1 小时前
游戏引擎学习第272天:显式移动转换
c++·学习·游戏引擎
有事没事实验室1 小时前
CSS 盒子模型与元素定位
前端·css·开源·html5
浩~~1 小时前
HTML5 中实现盒子水平垂直居中的方法
java·服务器·前端