Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom attribute gives parsing error when using with an angular 2.0.0-beta.0

I'm trying to use custom attribute with angular2 as following

 <a href="javascript:void(0)" title="{{inst.title}}" data-loc="{{inst.actionval}}">

which gives me following error

EXCEPTION: Template parse errors: Can't bind to 'loc' since it isn't a known native property

like image 948
Akhilesh Kumar Avatar asked Feb 20 '16 06:02

Akhilesh Kumar


1 Answers

Angular by default uses property binding but a doesn't have a property data-loc. To tell Angular explicitly to use attribute binding, use instead: try this one may work for you.

<a href="javascript:void(0)" title="{{inst.title}}" [attr.data-loc]="inst.actionval">

or

<a href="javascript:void(0)" title="{{inst.title}}" attr.data-loc="{{inst.actionval}}">
like image 113
Pardeep Jain Avatar answered Nov 05 '22 12:11

Pardeep Jain