본문 바로가기

프로그래밍/AngularJs

AngularJs 2 - index.html

웹앱의 시작점인 index.html을 만들어보자.



<!DOCTYPE html>
<html lang="en">
<head>
<title>First App</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<!-- 1. Load libraries -->
<!-- IE required polyfills, in this exact order -->
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="node_modules/angular2/es6/dev/src/testing/shims_for_IE.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<!-- 2. Configure SystemJS -->
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/main')
.then(null, console.error.bind(console));
</script>
</head>
<!-- 3. Display the application -->
<body>
<my-app>Loading...</my-app>
</body>
</html>
view raw index.html hosted with ❤ by GitHub


일반적인 html 구조이고, system.src.js의 함수가 사용되고 있다. 이 파일은 이전에 만든 package.json의 의존성에 의해 npm install 시에 설치되었다.


25번째 줄에 의해 29번째 줄의 import시에 main.js라고 써주지 않아도 된다.


36번째 줄의 <my-app> tag는 이후 만들 app.component.ts에서 참조 하게 된다.


* ts 는 TypeScript의 확장자이며, 이를 transpile 하여 생긴 결과가 js 파일이다.