angular-rc5

How to create an Http instance WITHOUT using constructor DI? (RC.5+) [duplicate]

强颜欢笑 提交于 2019-12-20 01:34:31
问题 This question already has an answer here : angular2 resolveAndCreate HTTP - missing HTTP_PROVIDERS in RC7 (1 answer) Closed 3 years ago . I need to get an instance of Http without using Angular2's DI ( constructor(private http: Http) ) The following code was taken from another stackoverflow question, and it works in Angular2 RC.4 and earlier versions, but not in RC.5+(HTTP_PROVIDERS is no longer available) : const injector = ReflectiveInjector.resolveAndCreate([ HTTP_PROVIDERS ]); this.http =

Angular 2 RC5 Testing Promises in ngOnInit Not Working

只愿长相守 提交于 2019-12-17 20:29:32
问题 I am trying to test a structural directive named MyDirective with Jasmine. The Angular version used is RC5. // Part of the MyDirective class @Directive({selector: '[myDirective]'}) export class MyDirective { constructor(protected templateRef: TemplateRef<any>, protected viewContainer: ViewContainerRef, protected myService: MyService) { } ngOnInit() { this.myService.getData() .then((data) => { if (!MyService.isValid(data)) { this.viewContainer.createEmbeddedView(this.templateRef); } else {