I am new to angular and I am currently using Angular 7. I can't add the variable to data-link property.
In my ts
file I have a variable :
export class PortfolioComponent implements OnInit {
var = "#item1";
}
And in HTML I have:
<li class="item group1" data-link="{{var}}">
text
</li>
But this doesn't work, and shows the following error:
Can't bind to 'link' since it isn't a known property of...
The
var
is reserved word in javascript - typescript so you can't use it like this.The
var
statement declares a variable.You can find all reserved words here enter link description here
This is how your code will work:
TS
HTML