1
根据http://blog.500tech.com/svg-in-angular-2/使SVG的内部组件,我们必须使用[属性]选择:如何将数据传递给嵌套(子)角2属性组件
// svgmap.componet.ts chunk of code: component declaration
@Component({
selector: '[svgmap]',
templateUrl: 'app/svg/map/svgmap.template.html'
})
我的方案本SVGMapComponent
在一些使用这样父组件模板:
<svg [attr.class]="mapClass[0]" svgmap="1"></svg>
<svg [attr.class]="mapClass[1]" svgmap="2"></svg>
<svg [attr.class]="mapClass[2]" svgmap="3"></svg>
到目前为止,它工作正常,但现在我需要用我试过的值传递的(在上面的例子如“1,2,3”)的svgmap属性值到svgmap.componet.ts
的代码中,但我不知道它是否是po ssibile和如何抓住它。
如果可能的话:我可以在我的打字稿子部件中使用什么语法(即:svgmap.componet.ts
)?
如果不可能:为什么?它存在一个工作?
P.S .:我读了一些帖子,如 https://www.themarketingtechnologist.co/building-nested-components-in-angular-2/,在某些情况下启发,但不适用于上述情况。
@peeskilled非常感谢你。我编辑的答案,因为与Angular 2的版本我使用该类型的规范是强制性的,并添加了一些可能非常有用的细节,特别是对于那些没有完全掌握Angular2的人 –