We can't use AtScript in existing projects yet (and Angular 2 will be ready even later than AtScript), but we already can use ES6 with AngularJS 1.3, best Angular yet (current stable branch), with all cool things ES6 going to give us. Take it now! :)
I'll show you how to do it on example of the project, bootstrapped by Yeoman's generator-angular. Maybe not top-notch folders structure, but easy to start with.
Source code of project:
Step 1 - install modules
When we have base of project, let's add components:
Grunt will transpile ES6 to ES5 (I know I know, Gulp is our new trend, but.. next time)
npm install grunt-traceur --save-dev
PhantomJS doesn't support ES5 even, so we will run unit tests in Chrome:
We need traceur runtime in app:
Step 2 - Structure
In structure of this project most convenient place I found for ES6 files is /app/es6 - I just copied content of 'scripts' folder here. Now I can use watch, livereload, build project and run tests. Awesome.
Step 3 - Gruntfile
Example of Gruntfile.js
And what has been changed in file, generated by generator-angular:
We add new task, 'traceur' and add it to build, test, serve tasks.
Step 4 - Unit tests config
Pretty simple changes:
replace PhantomJS by Chrome (it will run without taking focus, in background) and add traceur.min.js link.
Step 5 - index.html
Just add link to traceur.min.js
Now you can use ES6 in your AngularJS project. For example, I use ES6 classes for Services, because I like it and it works :)
Traceur will compile AtScript in the same way it compile ES6 for us in this project, so it's nice to meet Traceur already now and start use advantages of new technologies.