看代码。
import {Component} from 'angular2/core';
import {App} from 'client/project/project.app';
import {ProjectService} from 'service/project.service';
@Component({
selector: 'project-info',
templateUrl: 'client/project/info/project-info.html'
})
export class ProjectInfoComponent {
project:IProject;
constructor(
private app: App,
private projectService: ProjectService
){
this.project = this.app.selectedProject;
}
}
我在其他组件中更改了 this.app.selectedProject={...},我想重新渲染这个组件。怎么做?仅在使用 EventEmitter 时发明。
this.app.selectedProject.subscribe(project => {
this.project = project;
});