1
我一直在使用兩種方法將依賴關係注入到單元測試中,我想知道有什麼區別,以及如果一種方式更好,因爲最終結果是相同的。下面的兩個片段輸出相同的'calendarSvc'服務對象。
beforeEach(inject(function($injector) {
console.log(1, $injector.get('calendarSvc'));
}));
beforeEach(inject(function(calendarSvc) {
console.log(2, calendarSvc);
}));