typescript - Extending routerLink in angular 2? -
how can extend [routerlink] directive angular router v3 can wrap custom functionality myself? i've taken @ routerlinkwithhref directive , appears want extend, produced this:
extendedrouterlinkdirective
import {directive, input} '@angular/core'; import {routerlinkwithhref} "@angular/router"; import {model} "../classes/model.class"; @directive({ selector: 'a[extendedrouterlink]' }) export class extendedrouterlinkdirective extends routerlinkwithhref { @input('extendedrouterlink') model : model; // future custom logic } and try , use so:
<a [extendedrouterlink]="model"> and include in directives array of component:
... directives: [router_directives, extendedrouterlinkdirective], ... yet, following runtime error:
"template parse errors: can't bind 'extendedrouterlink' since isn't known native property"
if remove extends routerlinkwithhref directive, works without errors. doing wrong?
Comments
Post a Comment