Is it needed to learn TypeScript for Angular 2?
Can Angular 2 be used with plain JavaScript ?
Edit: I\'ve seen that the languages used as ES6, ES7, Dart comp
Yes.
Here are 2 simple components, written in different ways that Angular 2 supports when writing in JavaScript (EcmaScript 5):
(function() {
var HelloWorldComponent = function() {};
HelloWorldComponent.annotations = [
new ng.core.Component({
selector: 'hello-world',
template: 'Hello Angular2!
'
})
];
var HelloFlentApi = ng.core.Component({
selector: 'hello-fluent',
template: 'Hello {{name}}!
' + '',
}).Class({
constructor: function() {
this.name = "Fluent API";
}
});
var AppComponent = ng.core.Component({
selector: 'company-app',
template: ' ' +
' ',
directives: [HelloWorldComponent, HelloFlentApi]
}).Class({
constructor: function() {}
});
document.addEventListener("DOMContentLoaded", function() {
ng.platform.browser.bootstrap(AppComponent);
});
}());
Loading ...
I wrote a detailed explanation of the code here:
Writing An Angular2 Component in Today’s JavaScript (ES5) – Beta 0 Edition
As the link says, this applies to Angular 2 Beta 0, which was released a few hours ago at the time of writing this answer.