LoginSignup
1
1

More than 5 years have passed since last update.

Angular2 Todo Appを動作させてみた時のメモ

Posted at

AngularのYoutubeチャンネル An Angular2 Todo App: First look at App Development in Angular2 で紹介されていた、Angular2のTODOアプリを動作させてみた時のメモ。
2015/2/16現在の情報です。

インストール

まずはAngular2の取得

$ git clone https://github.com/angular/angular.git
$ cd angular
$ npm install

依存ライブラリインストール時にnode-gypでたくさんエラーがでたため、nodeのバージョンを0.10.xにしてみて再実行

$ nodebrew install-binary v0.10.36
fetch: http://nodejs.org/dist/v0.10.36/node-v0.10.36-darwin-x64.tar.gz
######################################################################## 100.0%
Install successful

$ nodebrew use v0.10.36
use v0.10.36

幾つかWARNは出てたけどうまく行ったぽい
gulpとprotractorもインストール

$ npm install -g gulp
$ npm install -g protractor
$ webdriver-manager update

ビルド

$ gulp build

Dart SDK is not available. Skipping task: build.dartと出るけど無視
/angular/dist/js/devができているか確認

$ ls -l dist/js/dev
total 0
drwxr-xr-x 8 272  2 17 00:28 es5
drwxr-xr-x 7 238  2 17 00:28 es6

es5es6ができているが、2/16時点のREADME.mdでは、

ln -s ~/angular/dist/js/dev ng

となっている。
pull/3にあるように、サブディレクトリを特定してシンボリックリンクを貼る。パスは適宜変更。

$ git clone https://github.com/davideast/ng2do.git
$ cd ng2do
$ ln -s ~/angular/dist/js/dev/es5 ng

サーバ起動

サーバ起動し、ブラウザからhttp://localhost:8000にアクセス

$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...

動かない。。
コンソールには以下のエラー

"Error during instantiation of Token(AppComponentAnnotatedType)!. ORIGINAL ERROR: TypeError: TemplateConfig is not a constructor

どうやらpull/5に上がっているのが原因ぽい。TemplateConfigTemplateに変更

todo.js
import {Component, Template, bootstrap, Foreach} from 'angular2/angular2';
todo.js
  ]
})
@Template({
  url: '/todo.html',
  directives: [Foreach]
})

の2箇所を修正したところ、Chromeで動作した。
(がFirefoxでは動作せず)

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1