Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
538 views
in Technique[技术] by (71.8m points)

ecmascript 5 - Is it possible to use ES5 JavaScript with Angular 2 instead of TypeScript?

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 compile to JavaScript to be executed, but I haven't seen any reference to use ES5 JavaScript directly.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Yes, you can.

Go read this guide. Pressing the ES5 tab on the code examples will show you regular ES5 JavaScript, as apposed to TypeScript.

The API preview is, for obvious reasons, incomplete though. So you may not find the ES5 methods listed there yet, and some of it may change before release.

Current example of Angular 2.0 main component in ES5.

function AppComponent() {}

AppComponent.annotations = [
  new angular.ComponentAnnotation({
    selector: 'my-app'
  }),
  new angular.ViewAnnotation({
    template: '<h1>My first Angular 2 App</h1>'
  })
];

document.addEventListener('DOMContentLoaded', function() {
  angular.bootstrap(AppComponent);
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...