I want to learn Angular 2 and switch my app to using it, however, I\'m having a problem with using TypeScript.
In my current environment I can\'t use a use the tran
If you want to use TypeScript to write your application, you need a transpiler:
tsc -w
command running in backgroundThat said it's possible to write Angular2 applications with ES5 only. Here is a sample:
Edit
When you include these JavaScript files fro Angular2 (folder node_modules/angular2/bundles
), there is nothing about TypeScript:
<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="node_modules/angular2/bundles/router.dev.js"></script>
<script src="node_modules/angular2/bundles/http.dev.js"></script>
These files were transpiled into JavaScript. So there is no need to have TypeScript. With them, you can implement your application with ES6 only.
To use ES5 only, you need to include these ones:
<script src="node_modules/angular2/bundles/Rx.umd.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/angular2/bundles/angular2-all.umd.dev.js"></script>
Angular2 is available in TypeScript, JavaScript and Dart. No need to use TypeScript.
See
- https://angular.io/docs/js/latest/index.html
- http://blog.thoughtram.io/angular/2015/05/09/writing-angular-2-code-in-es5.html
- http://blog.thoughtram.io/angular/2015/07/06/even-better-es5-code-for-angular-2.html
See also Is it possible to use ES5 JavaScript with Angular 2 instead of TypeScript?
<script src="https://code.angularjs.org/2.0.0-beta.3/Rx.umd.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.3/angular2-polyfills.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.3/angular2-all.umd.dev.js"></script>