实例化注入类时不调用 ngOnInit
2022-08-30 00:29:30
为什么在解析类时不调用?ngOnInit()
Injectable
法典
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()');
}
}
控制台输出
FROM constructor()