[译]Angular2 和TypeScript -- 一次简要的预览

前端开发 作者: 2024-08-21 11:15:02
原文链接:https://www.infoq.com/articles/Angular2-TypeScript-High-Level-Overview 作者: Yakov Fain Post
 1 @Component({
 2   selector: 'auction-home', 3   template: `
 4     HTML or other markup is in-lined here
 5   `
 6 })
 7 export default class HomeComponent {
 8 
 9  // Application logic goes here
10 }
import {Component} from 'angular2/core';
import {Route,RouteConfig,RouterOutlet} from 'angular2/router';
import HomeComponent from '../home/home';
import NavbarComponent from '../navbar/navbar';
import FooterComponent from '../footer/footer';
import SearchComponent from '../search/search';
import ProductDetailComponent from "../product-detail/product-detail";

@Component({
  selector: 'auction-application''/',component: HomeComponent,as: 'Home'},{path: '/products/:id',component: ProductDetailComponent,as: 'ProductDetail'}
])
export default class ApplicationComponent {}
export class ProductService {
  products: Product[] = [];
  getProducts(): Array<Product> {
     The code to retrieve product into goes here
    return products;
  }
}
@Component{
 ...
}
export  class HomeComponent {
  products: Product[] = [];

  constructor(productService: ProductService) {
    this.products = productService.getProducts();
  }
}
原创声明
本站部分文章基于互联网的整理,我们会把真正“有用/优质”的文章整理提供给各位开发者。本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
本文链接:http://www.jiecseo.com/news/show_66059.html