我正在关注本文https://medium.com/netscape/visualizing-data-with-angular-and-d3-209dde784aeb
应该可以将Angular @Directive绑定到svg:g元素,但是出现无法解决的错误
html模板
<svg #svg class="container-fluid" height="600">
<g zoomable [zoomableFor]="svg">
<rect width="600" height="600" fill="#ecf0f1" />
...
zoomable.directive.ts
@Directive({
selector: "[zoomable]"
})
export class ZoomableDirective implements OnInit {
@Input('zoomableFor') for: string;
谢谢。
compiler.js:2547未捕获的错误:模板解析错误:无法绑定到 'zoomable',因为它不是':svg:g'的已知属性。 (“
] [zoomable] =“ svg”> ) 在JitCompiler.push ../ node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileComponents (compiler.js:24971) 在compile.js:24881 在Object.then(compiler.js:2538) 在JitCompiler.push ../ node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents (compiler.js:24880)语法错误@ compiler.js:2547 推送../node_modules/@angular/compiler/fesm5/compiler.js.TemplateParser.parse @ @ compiler.js:19495 push ../ node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._parseTemplate @ compile.js:25041 push ../ node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileTemplate @ compiler.js:25028(匿名)@ compiler.js:24971 push ../ node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileComponents @ compiler.js:24971(匿名)@ compiler.js:24881,然后@ editor.js:2538 push ../ node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents @ compile.js:24880 push ../ node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler.compileModuleAsync @ compile.js:24840 push ../ node_modules/@angular/platform-browser-dynamic/fesm5/platform-browser-dynamic.js.CompilerImpl.compileModuleAsync @ platform-browser-dynamic.js:143 compileNgModuleFactory__PRE_NGCC__ @ core.js:14376 push ../ node_modules/@angular/core/fesm5/core.js.PlatformRef.bootstrapModule @ core.js:14559 ./src/main.ts @ main.ts:11 webpack_require @引导程序:78 0 @ main.ts:12 webpack_require @引导程序:78 checkDeferredModules @引导程序:45 webpackJsonpCallback @引导程序:32(匿名)@ main.js:1
其他@Components作为svg元素的属性起作用。