angular使用动态组件后属性值_javascript – Angular 2使用组件属性动态设置routerLink...

我创建了一个组件,其中包含一个带有routerLink属性的元素,我想从使用该组件的模板中设置该属性.当我尝试这样做时,我收到错误消息’无法读取属性’未定义’的路径’.

我的组件看起来链接这个:

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;

}

INFO-box.component.html

并且使用组件的模板看起来像这样:

如果我不添加routerLink一切正常.我的路由器配置似乎是正确的,因为当我直接添加到我的模板时,它也可以正常工作.谁能帮我这个?

Grt Marco

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值