使用angular2而不使用打印机编译器
我想学习和切换到angular2我的应用程序,但我有打字稿的问题。 问题是我无法使用它。 在我目前的环境中,我不能使用编译器。 即时通讯目前不得不运行node.exe(node.js可执行文件),但不是完整的node.js应用程序只是可执行文件,这意味着我不能运行npm。 但angular2写在打字稿,所以它需要被编译为JavaScript之前被发送到浏览器。 有没有办法我可以得到一个预编译版本的angular2(所以它在JavaScript中),所以我可以在JavaScript中编写我的代码,并让所有的东西没有编译器运行? 如果没有的话,你可以手动安装和使用typecript编译器只有node.exe可执行文件。
要清楚这是因为我不想使用打字稿这是因为在我目前的情况下,我不能安装打字稿。
Angular2可用于TypeScript,JavaScript和Dart。 不需要使用TypeScript。
看到
– 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
另请参见是否有可能使用ES5 JavaScript与Angular 2而不是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>
如果你想使用TypeScript来编写你的应用程序,你需要一个转译器:
- 静态的。 例如,在后台运行
tsc -w
命令 - 在飞行中。 在浏览器中直接使用typescript.js文件
这就是说可以用ES5编写Angular2应用程序。 这是一个示例:
编辑
当您将Angular2(文件夹node_modules/angular2/bundles
)中的这些JavaScript文件包含在内时,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>
这些文件被转换成JavaScript。 所以没有必要有TypeScript。 有了它们,您就可以仅使用ES6来实现您的应用程序。
要仅使用ES5,您需要包括这些:
<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>
- 如何在node.js服务器中提供angular2应用程序
- lb-ng loopback命令返回“Can not read property”apply as of undefined“from async module
- 如何closuresAngular 2/4 +和Socket.io中的websocket
- 节点 – 设置angular度cli环境
- 量angular器:browserName'chrome'不受directConnect支持
- 量angular器:text.indexOf(…).isDisplayed不是一个函数
- 如何永远与量angular器工作?
- Angular 2和NodeJs – 使用angular度为2的数据库连接variables调用NodeJs函数
- 响应中的'Access-Control-Allow-Credentials'标题是'',必须是'true'