美文网首页我爱编程
依照angular2-reddit-base学习Angular2

依照angular2-reddit-base学习Angular2

作者: 陈式坚 | 来源:发表于2017-08-08 15:20 被阅读0次

一定要使用TypeScript吗?

不,但是用起来更简单。

第一步,安装环境

  1. 安装 NodeJS
  2. 安装 TypeScript

npm install -g typescript

  1. 克隆 angular2-reddit-base

git clone https://github.com/antonsbox/angular2-reddit-base.git

  1. 进入目录,然后安装Node模块

cd angular2-reddit-base
npm i

  1. 新建一个index.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>来一发?</title>
<script src="node_modules/es6-shim/es6-shim.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/reflect-metadata/Reflect.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
</head>
<body>

<script src="resources/systemjs.config.js"></script>

<script>
System.import('app.js')
.then(null, console.error.bind(console));
</script>

<ni-hao></ni-hao>
</body>
</html>

目录结构

|-- index.html // 首页文件
|-- resources/ // 图片资源
|-- styles.css // 全局样式

认识app.ts

import { bootstrap } from "@angular/platform-browser-dynamic";
import { Component } from "@angular/core";
// 组件
@Component({
selector: 'div-title',
template: <h1>你好</h1>
})
// 类
class NiHao { }
// 渲染启动
bootstrap(NiHao);

在index.html中引入app.ts


放弃,教程太老。。。 没办法运行
真是的
。。
还是用官网教程把

相关文章

网友评论

    本文标题:依照angular2-reddit-base学习Angular2

    本文链接:https://www.haomeiwen.com/subject/jaozlxtx.html