Skip to content
Related Articles

Related Articles

How to create a hyperlink for values from an array in Angular 8?

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 11 Sep, 2020

In angular 8, we can create hyperlinks for all the values that are present in the array using *ngFor.

1) First declare and initialize array in .ts file.
2) Then use *ngFor directive for iterating through the array.
3) Using this *ngFor directive in .html file, we can use it as per the requirement.
4) Once the implementation is done then the serve the project.

Syntax for starting the project.

ng serve --open

Implementation by code:


<div *ngFor = "let item of data"
  <a [attr.href]="item.url">


import { Component } from '@angular/core';
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ 
     text-decoration: none;
     cursor: pointer
export class AppComponent  {


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!