I have a component which I inject a service. I try to bind the properties from the service to the component's html view.
I tried just to bind in a regular way <p>{{a}}</p> but it didn't work. I asked here and the answer I got was to refer to the service name first:
service:
export class MyService {
a: string = 'Hello world';
b: number = 1;
c(): number {
this.b += 1;
return this.b;
}
}
component.ts:
export class myComponent {
constructor(public myService: MyService){}
}
component.html:
<p>{{myService.a}}</p>
I did it and still doesn't work - what do I miss?
If I console the properties in the service methods, then call the method in the component class, it will console the properties. But once I try to bind them in the template - it's doesn't work.
Thanks.