The version of my TypeScript 1.7.5
My main component file
// import {Component} from 'angular2/core';
import {Component, View} from 'angular2/core';
// import {bootstrap} from 'angular2/platform/browser';
@Component({
selector: 'my-app',
// template: '<h1>My title: {{title}}</h1> <h2>Hardcoded h2</h2>'
})
@View({
templateUrl: '/templates/home.html',
directives: []
})
.Class({
constructor: function() {
}
})
export class AppComponent {
title = "My First Angular 2 App";
}
My HTML scripts
<!-- 1. Load libraries -->
<script src="node_modules/es6-shim/es6-shim.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>
<script src='app.component.js'></script>
<script src='app/boot.js'></script>
Next when I try to compile the file tsc app.component.ts --module system --experimentalDecorators
I get the following error: app.component.ts(2,31): error TS2307: Cannot find module 'angular2/core'.
Do you know what I'm missing here?
@Componentannotation instead.Class({ constructor: function() { } })stuff, that's not from a typescript example is it? your class is:export class AppComponent { title = "My First Angular 2 App"; }@Viewand moved thetemplateUrlto@Componant, but still when trying to compile it I getCannot find module 'angular2/core'Also isn't.Class({ contructor: function()the place where I can add logic? Do have have any sample code for a similar basic structure?export class AppComponentthat's where you add your logic, you can set the constructor on it.