Angular routing and svgPath
See original GitHub issueHi, I am trying to run trumbowyg within angularjs app and I found issue that makes it unusable.
This is code from trumbowyg.js that do that:
t.svgPath = !!t.doc.querySelector('base') ? window.location.href.split('#')[0] : '';
angularjs html5Mode requires base tag so window.location is used for svgPath, but it is not accurate as angulajs has its own $location. It brakes loading svg icons.
What is the purpose of this statement? Iframe? Thank you
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (5 by maintainers)
Top Results From Across the Web
How to use routerLink inside SVG path? - Stack Overflow
A way I found to do this is by adding a data attribute to the svg and dynamically assign the onclick event in...
Read more >SVG as templates - Angular
You can use SVG files as templates in your Angular applications. When you use an SVG as the template, you are able to...
Read more >How to create a route finder on an SVG map - Gearheart
So, drawPath is pretty straightforward: we create svg path element and set its attributes with the values passed in options argument. What is ......
Read more >Angular Animate Svg Path (forked) - StackBlitz
A angular-cli project based on rxjs, tslib, core-js, zone.js, @angular/core, @angular/forms, @angular/common, @angular/router, @angular/compiler, ...
Read more >[Solved]-Angular SVG Path Not Visible-angular.js
Related Query · Angular SVG Path Not Visible · Angular 6 route path not working for direct url when deployed in subdirectory ·...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This probably won’t fix anything for you, since you seem to refer to the old AngularJS (1), while this is for Angular (2+), but since others might run into it, here’s what I did for Angular (with Angular CLI): To get the script working in the first place, it needs to go into
.angular-cli.json
script section, along with JQuery and plugins:To get the CSS to a known directory, you need to make sure that the CLI packages it into the app, on a known location, using the assets section (
assets
andfavicon.ico
are there by defaults. I left them in for context):(One could probably get away with just copying it to assets, but I preferred leaving it in place)
Then, in
main.ts
, set the trumbowyg svgPath:$.trumbowyg.svgPath = 'dist/icons.svg';
Optional: This doesn’t really work for me, since I have a weird issue where stuff breaks when using JQuery typings with AOT, so I had to go back to
any
for jQuery plugins, but I made a TypeScript Typings file for Trumbowyg that I believe is reasonably correct: https://gist.github.com/LosD/7d8b7d0c77be2cb92f4b309f1a3353b8@Alex-D If you know anything about TypeScript, I’d love a review of the typings for correctness, then I can submit them to DefinitelyTyped, so TypeScript users has the typed API (one thing I know I should probably fix, is that only the JQuery interface is in the public namespace).
OK, sorry, I understand the problem, but you were unclear.
Did you think that can do the job:
svgBasePath
should be your base path.