newsComponent template logic
You will have noticed that when we created the component from Angular CLI, it created a separate file for the template. We will be using this file to define our HTML for news details and bind the news property which we defined in the component to display the data.
As our news articles are a list, we will be using one of the built-in Angular structural directives, *ngFor. Angular has predefined directives called structural directives, which enable us to change the structure of the HTML at runtime based on the input provided. These directives add power and flexibility to our HTML by providing features such as for loops and if logic. Here, we are using ngFor to loop through our list of news articles and print each ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access