Angular-get started

https://angular.io/start#whats-next
Getting started with Angular
Welcome to Angular!
This tutorial introduces you to the essentials of Angular by walking you through building an e-commerce site with a catalog(mulu), shopping cart, and check-out form.

To help you get started right away, this tutorial uses a ready-made application that you can examine and modify interactively on StackBlitz without having to set up a local work environment.
StackBlitz is a browser-based development environment where you can create, save, and share projects using a variety of technologies.

Prerequisites xianjuetiaojian
To get the most out of this tutorial you should already have basic understanding of the following.
-HTML
-JavaScript
-TypeScript

Take a tour of the example application
You build Angular applications with components. Components define areas of responsibility in the UI that let you reuse sets of UI functionality.

1. A components consists of three things: 组件
- A component class that handles data and fuctionality.
- An HTML template that determines the UI.
- Component-specific styles that define the look and feel.

This guide demonstrates building an application with the following components.
- <app-root> the first component to load and the container for the other components.
- <app-top-bar> the store name and checkout button.
- <app-product-alerts> a component that contains the applicaiton's alerts.
For more information about components, see Introduction to Components.

2. create the sample project 创建工程
To create the sample project, generate the read-made sample project in StackBlitz. to save your work:
1. Log into StackBlitz.
2. Fork the project you generated.
3. Save periodically. 周期性的存储
----------------------------------------
还是本地建立工程吧
https://angular.io/guide/setup-local
----------------------------------------
In StackBliz, the preview pane on the right shows the starting state of the example applcation.
The preview features two areas:
进去了发现做的很逼真,厉害。
- a top bar with the store name, My Store, and a checkout button.
- a header for a product list, Products.
The project section on the left shows the source files that make up the application,
including the infrastructure and configuartion files.
When you generate the StackBlitz example applications that accompany the tutorials,
StackBlitz creates the starter files and mock data for you. The files you use throughout the tutorial are in the src folder.

For more information on how to use StackBlitz, see the 
https://developer.stackblitz.com/docs/platform/

3. Create the product list
In this section, you'll update the application to display a list of products.
You'll use predefined product data from the products.ts file and methods from the product-list.component.ts file.
This section guides you through editing the HTML,also known as the template.
1) In the product-list folder, open the template file prodcut-list.component.html.
2) Add an *ngFor structural directive on a <div>, as follows.
src/app/product-list/product-list.component.html
<h2>Products</h2>
<div *ngFor="let product of products">
</div>
With *ngFor, the <div> repeats for each product in the list.
Structural directives shape or reshape the DOM's structure, by adding, removing, and maniplulating elements. 
For more information about structural directives, see
https://angular.io/guide/structural-directives

3. Inside the <div>, add an <h3> and {{product.name}}.
The {{product.name}} statement is an example of Angular's interpolation syntax.插值语法
Interpolation {{}} lets you render the property value as text.

src/app/product-list/product-list.component.html
<h2>Products</h2>
<div *ngFor="let product of products">
  <h3>
    {{product.name}}
  </h3>
</div>
The preview paneupdates to display the name of each product in the list.


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值