2 ms·
I don't understand how that correlates to the current DI. How do I rewrite the following using the new DI system? function MyCtrl($http, Base64) { $http.
by Kiro 13y ago
I don't understand how that correlates to the current DI.
How do I rewrite the following using the new DI system?
function MyCtrl($http, Base64) {
$http.get('http://www.example.com').success(function (data) {
console.log(Base64.decode(data));
});
}
- nateabele 13y agoimport {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.