Why isn't ngOnInit()
called when an Injectable
class is resolved?
(解析Injectable
类时,为什么不ngOnInit()
?)
Code
(码)
import {Injectable, OnInit} from 'angular2/core';
import { RestApiService, RestRequest } from './rest-api.service';
@Injectable()
export class MovieDbService implements OnInit {
constructor(private _movieDbRest: RestApiService){
window.console.log('FROM constructor()');
}
ngOnInit() {
window.console.log('FROM ngOnInit()');
}
}
Console Output
(控制台输出)
FROM constructor()
ask by Levi Fuller translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…