未来打样角应用与ES6功能 [英] Future proofing Angular apps with ES6 features

查看:86
本文介绍了未来打样角应用与ES6功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是写控制器,服务和指令在ES6(使用Traceur),使得最相同$ C $的c可以与AngularJS 2.0中使用的建议(如果有一个)面向未来的方式。我认识到,AngularJS 2.0仍然是在绘图板上,但如果我要开始一个新的应用程序今天做什么风格或约定我跟着这么迁移到2.0将有希望减少痛苦。

What is the recommended (if there is one) future-proof way to write controllers, services and directives in ES6 (using Traceur) so that the most of same code can be used with AngularJS 2.0. I realize that AngularJS 2.0 is still on the drawing board but if I were to start a new app today what style or conventions do I follow so migrating to 2.0 will hopefully be less painful.

声明一个类,然后传递引用的那类到控制器服务一点我见

Declaring a class and then passing a reference to that class into the controller or service is one point i see:

var app = angular.module('myApp', []);

class MainCtrl {
   ....
}

class MyService {
   ....
}

app.controller('MainCtrl', MainCtrl);
app.service('MyService', MyService);

如果为MyService 类被移动到一个单独的文件,这样可能在未来我可以只导出它并提供给被注入?

Should the MyService class be moved to a separate file so that potentially in the future I could just export it and have it available to be injected?

什么是一些其他的事情要记住,因为我使用AngularJS一个新的项目工作(小于= 1.3.x版)?和ES6

What are some other things to keep in mind as I work on a new project using AngularJS (<= 1.3.x) and ES6?

更新
一些周围挖后,我写了一系列博客文章在我的博客谈论我发现

Update After some digging around I wrote a series of blog posts talking about my findings on my blog

推荐答案

角团队ngEurope证实今天1.x中的$控制器,$范围,$服务和jqLit​​e将停止在角2.0存在。也将有一个全新的路由器,他们打算反向移植到1.3在未来几个月内。

The angular team at ngEurope confirmed today that the $controllers, $scopes, $services and jqLite of 1.x will cease to exist in Angular 2.0. There will also be a brand new router, which they intend to backport to 1.3 in the coming months.

要prepare迁移他们建议只是遵循最佳实践/风格/ 的约定已在社会发展至今,当2.0准备(明年的某个时候),他们将制定出从那里迁移的最佳途径。

To prepare for migration they suggested just following the best practices/styles/conventions that have evolved in the community so far, and when 2.0 is ready (sometime next year), they'll work out the best way to migrate from there.

此外,他们表示,1.3将全面支持至少一年的2.0发布后半了。

Also, they said that 1.3 will be fully supported for at least a year and a half after the release of 2.0.

这篇关于未来打样角应用与ES6功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆