In this example, there are 3 main components:
The first component is A.component.ts: This is the parent component where an HTTP call is made to retrieve a response.
const res = this.http.post("https://api.com/abcde", {
test: true,
});
res.subscribe((res) => {
this.itemID = res.item.id; // I am able to get this ID
});
The second component is B.component.html: This component is responsible for showing/hiding content on a page.
<app-ab-test [showMe]></app-ab-test>
The third component is ab-test.component.ts: This is the actual component used within B.component.html
@Input() public showMe = false;
ab-test.component.html:
<div *ngIf="showMe">
<img>
</div>
It would be beneficial to connect the this.itemID
value to control the boolean value of showMe
.
I am still learning and have been able to make it work up to this point. Any guidance you can provide will be greatly appreciated.