[Angular 2] 0. RC6: Start with Angular2

Create a index.html:

<!DOCTYPE html>
<html>
<head>
    <title>Really Understanding Angular 2 - The Fundamentals</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link href="//fonts.googleapis.com/css?family=Roboto:400,300,500,400italic,700" rel="stylesheet"  type="text/css">
    <link href="//fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <link rel="stylesheet" href="https://angular-academy.s3-us-west-1.amazonaws.com/styles/angular-academy-lessons-theme-v1.css">

    <!-- Polyfill(s) for older browsers -->
    <script src="https://npmcdn.com/core-js/client/shim.min.js"></script>

    <script src="https://npmcdn.com/[email protected]?main=browser"></script>
    <script src="https://npmcdn.com/[email protected]"></script>
    <script src="https://npmcdn.com/[email protected]/dist/system.src.js"></script>
    <script src="/system.config.js"></script>
    <script>
        document.SYSTEMJS_CONFIG.map.app = ‘.‘;
        document.SYSTEMJS_CONFIG.packages.app = {main: ‘hello_world.ts‘, defaultExtension: ‘ts‘};
        System.config(document.SYSTEMJS_CONFIG);
        System.import(‘app‘).catch(function (err) {
            console.error(err);
        });
    </script>
</head>
<body>
    <header class="l-header v-center-parent">
        <img class="v-center" src="//material.angularjs.org/latest/img/icons/angular-logo.svg">
    </header>
    <main class="l-main">
        <div class="l-course-logo"></div>
        <div class="l-course-title">Really Understanding Angular 2 - The Fundamentals</div>
        <div class="l-lesson-title">MVC Hello World Component - Controllers and Templates</div>
        <div class="l-course-content card card-strong lesson-1">
            <!-- Insert your module here -->
        </div>
    </main>
</body>
</html>    

Index.html works as an App Shell, which render meanful pixel onto the screen. And our module will be rendered when the data binding is ready.

Create first Module:

This module will bootstrap our application, normally this only happen once. This is the main entry point of the whole application.

import {Component, NgModule} from "@angular/core";
import {platformBrowserDynamic} from "@angular/platform-browser-dynamic";
import {BrowserModule} from "@angular/platform-browser";
@Component({
    selector: ‘app‘,
    template: `<h1>Hello Angular 2</h1>`
})
export class App{

}

/*
* Declare the NgModule
* */
@NgModule({
    declarations: [App],       // tell which component will be include into this module
    imports: [BrowserModule],  // if building web app, we need to use BrowserModule, native mobile app use other module
    bootstrap: [App]           // App component will be the entry point of the whole application
})
export class AppModule{

}

// Bootstrap the AppModule
platformBrowserDynamic().bootstrapModule(AppModule);

Last insert out App into html:

        <div class="l-course-content card card-strong lesson-1">
            <app></app>
        </div>
时间: 2024-08-27 15:55:58

[Angular 2] 0. RC6: Start with Angular2的相关文章

Angular 2.0 从0到1 (六)

第一节:Angular 2.0 从0到1 (一)第二节:Angular 2.0 从0到1 (二)第三节:Angular 2.0 从0到1 (三)第四节:Angular 2.0 从0到1 (四)第五节:Angular 2.0 从0到1 (五)第六节:Angular 2.0 从0到1 (六)第七节:Angular 2.0 从0到1 (七)第八节:Angular 2.0 从0到1 (八)番外:Angular 2.0 从0到1 Rx-隐藏在Angular 2.x中利剑番外:Angular 2.0 从0到

Angular 2.0 从0到1 (四)

第一节:Angular 2.0 从0到1 (一)第二节:Angular 2.0 从0到1 (二)第三节:Angular 2.0 从0到1 (三)第四节:Angular 2.0 从0到1 (四)第五节:Angular 2.0 从0到1 (五)第六节:Angular 2.0 从0到1 (六)第七节:Angular 2.0 从0到1 (七)第八节:Angular 2.0 从0到1 (八) 番外:Angular 2.0 从0到1 Rx-隐藏在Angular 2.x中利剑番外:Angular 2.0 从0

Angular 2.0 从0到1 (七)

第一节:Angular 2.0 从0到1 (一)第二节:Angular 2.0 从0到1 (二)第三节:Angular 2.0 从0到1 (三)第四节:Angular 2.0 从0到1 (四)第五节:Angular 2.0 从0到1 (五)第六节:Angular 2.0 从0到1 (六)第七节:Angular 2.0 从0到1 (七)第八节:Angular 2.0 从0到1 (八)番外:Angular 2.0 从0到1 Rx-隐藏在Angular 2.x中利剑番外:Angular 2.0 从0到

Angular 1.0演变Angular 2.0的简单优势列举

首先,Angular最核心的4大特性分别是: 1.模块化 2.MVC 3.双向数据绑定 4.指令 Angular 1.0演变Angular 2.0的简单优势列举: 1.性能限制上的优化 说明:随着时间的推移,各种特性被加入进去以适应不同场景下的应用开发,在最初的架构受到了限制,而Angular 2.0很好的解决了这些问题. 2.仿照WEB后端的结构模式来编写前端 说明:支持模块.类.lambda表达式. generator等新的特性 3.支持移动端开发 说明:Angular1.x没有针对移动 应

All About Angular 2.0

angular All About Angular 2.0 Posted by Rob Eisenberg on  November 6th, 2014. Have questions about the strategy for Angular 2.0? This is the place. In the following article I'll explain the major feature areas of Angular 2.0 along with the motivation

Angular 2.0 的设计方法和原则

转载自:Angular 2.0 的设计方法和原则 在开始实现Angular 2.0版本之际,我们认为应该着手写一些东西,告诉大家我们在设计上的考虑,以及为什么做这样的改变.现在把这些和大家一起分享,从而有助我们做出正确选择. Angular 2 是一个针对移动应用的框架.它同时也支持桌面环境,但是移动端是难点,我们把它放在第一位.你了解并且喜爱的Angular还在那里,数据绑定,可扩展的HTML,以及专注可测试开发. Angular 2 所有的设计文档都公开在Google Drive上.而这篇文

Angular 2.0 和 1.x比较

奥斯本效应 Angular团队面临着这样的问题:如何在不影响1.x版本使用的情况下谈论很多2.0的高级新功能.这就是奥斯本效应,上个世纪80年代的电脑公司,终因市场源于而歇业后命名.简而言之,2.0版本听起来越好,就越少有人去使用1.x版本.不同的是,Angular 2.0版本已经可以从github上通过npm install [email protected]2.0.0-alpha.6 得到它了.但是,这个不能用于生产,它还在被大量的修改. Angular 1.x vs. 2.0 为什么Ang

[转贴]有关Angular 2.0的一切

对Angular 2.0的策略有疑问吗?就在这里提吧.在接下来的这篇文章里,我会解释Angular 2.0的主要特性区域,以及每个变化背后的动机.每个部分之后,我将提供自己在设计过程中的意见和见解,包括我认为仍然需要改进设计的重要部分. 注意:本文所反映是2014年11月6日的状态记录.如果你在较长时间之后读到此文,请检查一下我设计上是否有所变更. AngularJS 1.3 在开始讨论Angular的未来之前,我们先花点时间看看当前的版本.AngularJS 1.3是迄今为止最优的Angula

Angular 2.0 基础:服务

什么是服务(Service) 在Angular 2 中我们提到的服务 service 一般指的是 哪些能够被其他组件或者指令调用的 单一的,可共享的 代码块.当然,通过服务可以将数据和组件分开,这样就可以实现更多的组件共享服务数据,服务能够使我们提高代码的利用率,方便组件之间共享数据和方法,方便测试和维护.在Angualr 文档中我们能看到这样的描述: Multiple components will need access to hero data and we don't want to c