I implemented jQuery dataTable to showcase data on a list view. In my attempt to populate data into the dataTable, I used the following approach.
Within users.component.ts:
getUsers() {
this.UserService.getUsersList()
.subscribe(
success => {
this.userList = success;
$("#userTable").find('tbody').empty();
var dataClaims = this.userList;
for (let i = 0; i < dataClaims.length; i++) {
$('#userTable').dataTable().fnAddData([
(i + 1),
dataClaims[i].name,
dataClaims[i].email,
dataClaims[i].contact_number,
dataClaims[i].address,
'<a [routerLink]="[' +"'"+"../../user/update" +"'" +']"' + ' class="fa fa-1x fa-pencil-square-o"></a>',
]);
}
}
);
}
The above function performs correctly, and the dataTable operates without any problems.
However, [routerLink]
does not get converted to HTML as expected. It displays this way in the output:
<a [routerlink]="['../../user/update']" class="fa fa-1x fa-pencil-square-o"></a>
Ideally, it should be transformed into the following format:
<a _ngcontent-c0="" ng-reflect-router-link="user/update" href="/user/update" class="fa fa-1x fa-pencil-square-o"></a>
Could anyone offer guidance on how to convert [routerLink]
to a standard link when rendering HTML data from a .ts file? Thank you.