【发布时间】:2016-09-15 20:48:45
【问题描述】:
我不明白什么时候使用@Inject,什么时候使用@Injectable?
import {Component, Inject, provide} from '@angular/core';
import {Hamburger} from '../services/hamburger';
export class App {
bunType: string;
constructor(@Inject(Hamburger) h) {
this.bunType = h.bun.type;
}
}
还有..
import {Injectable} from '@angular/core';
import {Bun} from './bun';
@Injectable()
export class Hamburger {
constructor(public bun: Bun) {
}
}
【问题讨论】:
标签: dependency-injection typescript angular injectable