I've followed the Angular 2 Quickstart guide but get the following error:
Error during instantiation of Token(AppView)!. ORIGINAL ERROR: Error: No template found for MyAppComponent
This is the relevant code:
import {Component, View} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser'
// Note I've changed Template to View here as I think it is a typo
....
@View({
template: '<h1>Hello {{ name }}</h1>'
})
....
Following Duncan Booth's suggestion here http://blog.ionic.io/angular-2-series-introduction/ I made the changes below and everything works:
import {Component, Template} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
....
@Template({
inline: "<h1>Hello {{ name }}</h1>"
})
....
But yesimahuman's comment at the same link mentions that "View is the new syntax" which does seem to be the case as is shown in the Plunker from the Angular 2 Step by Step Guide.
So why is the Quickstart code throwing an error and what is the correct fix?
I think you need to check this out
import {Component, Template, bootstrap} from 'angular2/angular2';
@Component({
selector: 'my-app'
})
@Template({
inline: '<h1>Hello {{ name }}</h2>'
})
class MyAppComponent {
constructor() {
this.name = 'Alice';
}
}
bootstrap(MyAppComponent);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With