问题
window.onload = function() {
svgPanZoom('#demo-tiger', {
zoomEnabled: true,
controlIconsEnabled: true
});
};
the above code doesn't work with Angular ??
回答1:
I have used svg-pan-zoom 3.5.x version, following code snippet may help you to import the library.
// Psuedo angular TS code
import * as SvgPanZoom from 'svg-pan-zoom';
@Component({
selector: 'app-svg-container',
templateUrl: './svg-container.component.html',
styleUrls: ['./svg-container.component.scss']
})
export class SvgContainerComponent implements OnInit, AfterViewInit {
constructor() { }
ngOnInit() { }
ngAfterViewInit() {
// initializing the function
let svgPanZoom: SvgPanZoom.Instance = SvgPanZoom('#wolrd-map-svg', this.options);
/* see typing definiton for more APIs. */
}
... More Codes...
}
来源:https://stackoverflow.com/questions/46455932/how-to-use-svg-pan-zoom-library-with-angular4