I 'm using angular7 , and here is my code : in component.ts
import { Component, OnInit } from "@angular/core";
import { FocusAreasService } from "../../services/focus-areas.service";
@Component({
selector: "app-about",
templateUrl: "./about.component.html",
styleUrls: ["./about.component.scss"]
})
export class AboutComponent implements OnInit {
public canonical: string;
public RsFocusArea: any[];
constructor(public focusareaService: FocusAreasService) {}
ngOnInit() {
this.canonical = document.location.origin;
this.focusareaService.getFocusAreaDataWithHttpClient2().subscribe({
next(response) {
console.log("HttpClient handle data");
console.dir(response);
this.RsFocusArea = response["focusArea"];
//I print this.RsFocusArea here , it has values
console.log("this.RsFocusArea");
console.dir(this.RsFocusArea);
},
error(err) {
console.error("Error: " + err);
},
complete() {
console.log("Completed");
}
});
}
}
}
and in .html
<ul class="col-xs-12 row">
<li *ngFor="let area of RsFocusArea" class="col-xs-12 col-sm-6 col-md-4">{{area}}
</li>
</ul>
and the li tage did not repeat and gave me this in tag structure:
<ul _ngcontent-aly-c5="" class="col-xs-12 row"><!--bindings={}--></ul>
<!--bindings={}-->
<ul _ngcontent-aly-c5="" class="col-xs-12 row"><!--bindings={}--></ul>
Is there anything wrong with my code? I thought maybe I need to rerender the page when I assign new value to RsFocusArea in ngOnInit?