3 ms·
The new DI looks confusing. The old way is super simple to understand. You inject the location provider and call it. In the new way however I don't understand w
by Kiro 13y ago
The new DI looks confusing. The old way is super simple to understand. You inject the location provider and call it. In the new way however I don't understand what's going on at all.
Where can I find a simple example?
- quest88 13y agohttps://github.com/angular/di.js/blob/master/example/kitchen-di/fridge.js https://github.com/angular/di.js/blob/master/example/kitchen... Seems pretty simple, imo.
- Kiro 13y agoI 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.