I'm trying to optimize my angular app and try to use ChangeDetectionStrategy.OnPush.
I get a data from server in the services, and everything works when ChangeDetectionStrategy is don't specified.
Now it look like
export class Some{
public name: string;
}
@Injectable()
export class Service {
public items: Some[] = [];
constructor(http: HttpClient) {
this.getModel();
}
getModel{
this.http.get("some_url").subscribe((result: Some[])=>{
this.items = result;
}
}
}
@Component({
template: '<ul><li *ngFor="let item of service.items">{{item.name}}</li></ul>',
})
export class Component implements OnInit {
constructor(private service: Service) {
}
ngOnInit() {
}
}
How do push service data to component?