2
我有調用此函數ngOnInit()中的組分不鏢調用angular2
class OtherComponent {
// ChromeCast receveiver event handler
onLoad() {
this.router.navigate(["/Video", { 'pageData': pageData}]);
}
}
要加載稱爲video_component.dart另一個鏢成分的app_component.dart。
import 'package:angular2/angular2.dart';
import 'package:angular2/common.dart';
import 'package:angular2/router.dart';
import 'dart:js';
import 'dart:html';
@Component(selector: 'video-container', templateUrl: '../../views/video_component.html', directives: const [NgFor])
class VideoComponent implements OnInit {
@Input()
ContentService contentService;
LoggerService log;
String progress;
RouteParams routeParams;
var pageData;
VideoComponent(@Inject(ContentService) this.contentService, @Inject(LoggerService) this.log, this.routeParams) {
log.info('constructor called'); // <== constructor is called
}
@override
ngOnInit() {
log.info('ngOnInit:Load video page with content Id');
//not called
}
}
爲什麼不ngOnInit()
不會被調用?
'(@Inject(ContentService)'是多餘的,如果參數是一個類型的話,這個參數也適用於'this.someField'類型的參數,最後一句看起來不完整 –
yes。 Future()「編譯器說'Undefined class Future' –
什麼是'onLoad()'事件,它來自哪裏? –