I have a simple app that fetches data from sample API. Trying to figure out whats wrong when defining a directive as a component:
app.ts
import {Component, View, bootstrap, For} from 'angular2/angular2'; import {ArticlesSvc} from 'services/articlesSvc'; import {ArticleItem} from 'directives/ArticleItem'; @Component({ selector: 'main-app', injectables: [ArticlesSvc] }) @View({ template: `<p *for="#post of posts">{{ post.title }} <article-item [body]="post.body"></article-item></p>`, directives: [For,ArticleItem] }) class MainComponent { posts: Array<string>; constructor(articlesSvc: ArticlesSvc) { this.posts = []; articlesSvc.get('http://jsonplaceholder.typicode.com/posts').then((data) => { this.posts = data; }); } } bootstrap(MainComponent); And here is ArticleItem component:
import {Component, View} from 'angular2/angular2'; @Component({ selector: 'article-item', properties: ['body'] }) @View({ template: `<p>{{ body }}</p>` }) export class ArticleItem { body:string; } For some reason, it gives me Unexpected number error. How to properly connect these two components? And is it a proper way to define a sub-components with its own view?