简体   繁体   中英

Kendo UI Angular Grid Template With Router Link

Is it possible to use routerLink in grid template with id parameter?

Ex:

<kendo-grid-column field="Garin" title="name" width="120" headerClass="THtheme">
                 <ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
                    <a [routerLink]="../Details/{{dataItem.Id}}" >{{dataItem.Name}}</a>
                </ng-template>
</kendo-grid-column>

when I try to do it I got error:

"Template parse errors.... Got interpolation ({{}}) where expression was expected"

Does anyone know if it possible and how? (not by code on click event....)

thanks

The error is because you are trying to use a interpolation to assign a property which is not supported/allowed. ( Reference )

But the routerLink directive can either take a string or an array of objects as parameter. ( Reference )

The way to go, in this case, is to use the second variant:

<a [routerLink]="['../Details', dataItem.Id]">{{dataItem.Name}}</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM