3 ms·
import {Http} from 'angularjs/http'; import {Base64} from './base64'; @Inject(Http) @Inject(Base64) export class MyCtrl { constructor(Http, Base64)
by nateabele 13y ago
import {Http} from 'angularjs/http';
import {Base64} from './base64';
@Inject(Http)
@Inject(Base64)
export class MyCtrl {
constructor(Http, Base64) {
Http.get('http://www.example.com').success(function (data) {
console.log(Base64.decode(data));
});
}
}
Not too bad, right?
- wildpeaks 13y agoIsn't this line missing? import {Inject} from 'di/annotations';
- Cthulhu_ 13y agoI don't like it at all; the Http and Base64 imports require three tokens / lines to import, while the existing DI just needed one. RequireJS requires two (array entry, callback parameter). I'll stick to ES 5 / Angular 1.2 if we're required to write this much boilerplate to achieve the same thing.