I created a component that contains an element with the routerLink property that I want to install from a template that uses this component. When I try to do this, I get the error "Unable to read property" path "from undefined".
My component looks like this:
info-box.component.ts
import { Input, Component } from "@angular/core";
import { ROUTER_DIRECTIVES } from "@angular/router";
@Component({
selector: "info-box",
template: require("./info-box.component.html"),
directives: [
ROUTER_DIRECTIVES
]
})
export class InfoBoxComponent {
@Input() routerLink: string;
@Input() imageUrl: string;
}
o-box.component.html
<a [routerLink]="[routerLink]">
<img src="{{imageUrl}}" width="304" height="236">
</a>
And the template in which the component is used is as follows:
<info-box [routerLink]="['/test']" [imageUrl]="['./testimage.jpg']"
If I do not add routerLink, everything works fine. My router configuration seems correct, because when I add directly to my template, it also works great. Can anyone help me with this?
Gret Marco