Properties-objects in a template in Angular
You can also output objects in the layout. Let's see in practice. Let's say we have the following object:
export class AppComponent {
public obj = {'a': 1, 'b': 2, 'c': 3};
}
Let's display the contents of our object in the layout:
<div>
{{ obj.a }}
{{ obj.b }}
{{ obj.c }}
</div>
The following object is given:
export class AppComponent {
public user = {
name: 'john',
surn: 'smit',
};
}
List each element of this object in a separate paragraph.
The following object is given:
export class AppComponent {
public user = {
img: 'pic.png',
alt: 'picture',
};
}
Output the elements of this object as the following markup:
<img src="pic.png" alt="picture">