3
我有以下service
:服务构造函数如何在角度2中实例化?
import {Injectable} from 'angular2/core';
import {Service2} from './app.service2';
@Injectable()
export class Service1 {
constructor(service2:Service2) {
this.service2 = service2;
}
getData() {
return this.service2.getData();
}
}
我使用我的组件之一这项服务,但我不知道这如何service
收到的service2
作为参数? Tradionion,在JS我做这样的事情。
var s = new Service1(service2);
但是我在下面的文章中没有看到类似的东西,但它起作用。 https://plnkr.co/edit/PsySVcX6OKtD3A9TuAEw?p=preview
任何人都可以在此添加一些光。