Is it possible to use relative paths (to use images) inside include?

2,207 views
Skip to first unread message

Ice Tea

unread,
Feb 22, 2013, 9:09:41 AM2/22/13
to ang...@googlegroups.com
Hi, I have something like
\index.html
\templ\page1.html
\templ\image1.jpg

If I include page1.html inside index.html, and page1.html have <img src="image1.jpg" />, it will not work.

Thanks

Clint Checketts

unread,
Feb 22, 2013, 10:12:17 AM2/22/13
to ang...@googlegroups.com
That sounds correct, the page being rendered in the browser is index.html so paths need to be relative to it.

You can build the path to the image file dynamically using ng-src.

-Clint



--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Peter Bacon Darwin

unread,
Feb 22, 2013, 11:31:55 AM2/22/13
to ang...@googlegroups.com

Your image urls  are local to the current html page unless you change that with a base tag.
Which in this case is the index.html

Pete
...from my mobile.

--

Ice Tea

unread,
Feb 22, 2013, 3:55:06 PM2/22/13
to ang...@googlegroups.com
Alright, thanks. I was hoping for some magic here, but unless I'd use node or something there is no way to find out the file location in the filesystem.

Peter Bacon Darwin

unread,
Feb 22, 2013, 4:12:55 PM2/22/13
to ang...@googlegroups.com
What I mean is that it is relative to the index.html page, not to the partial.  This should be fairly straightforward no?

Mohamed Kamal Kamaly

unread,
Oct 6, 2014, 3:30:50 PM10/6/14
to ang...@googlegroups.com
Sorry to reply on an old post, but I was having the same issues that the paths inside a
partial are relative to index.html not the partial location, so I created a module that allows that.

https://github.com/mohamedkomalo/angular-relative-paths-in-partial

Thanks
Reply all
Reply to author
Forward
0 new messages