-1

I am trying to load a JSP page inside a modal in AngularJS.

The JSP page have lot of scripts and so I wont be able to take the source and create a separate template. The URL is from a different server but I have CORS enabled in my server. Is there someway we can include the file in a div using ng-include src=""? I already tried this but it is not working. Can anyone recommend a solution?

Phoenix
  • 285
  • 9
  • 28

1 Answers1

0

You are not writing a valid code the code should be like this:

<div ng-include="'file path'"></div>

Note: Make sure of single inverted comma within double inverted comma. And file path can be of your any absolute path. Do not write src while using ng-include.

  • But the JSP I am trying to include is not a local file. It is in a different server (https://g****s.com/som/staticText.lvp?dialogContentType=5). I want a solution to take the template from the URL and then show it in a div. – Phoenix Aug 21 '17 at 09:23
  • Have you tried this exact url ? (https://g****s.com/som/staticText.lvp?dialogContentType=5) in my code – Gaurav Sharma Aug 21 '17 at 09:25
  • yes its not working. Thats why I tried ng-include src format which didnt work as well. – Phoenix Aug 21 '17 at 09:27
  • Probability 1 I think you are trying to access some application session page so it will not allow to load that page. Probability 2 Or you try to run your application on local absolute path am assuming that you are not using any server on your local machine because ng-include works on server only. – Gaurav Sharma Aug 21 '17 at 09:40
  • I am trying to access the page on a different server. Suppose I want to display "www.google.com" inside a div in my angular application, how will i achieve that? That is what I am trying to ask. – Phoenix Aug 21 '17 at 11:11
  • Finally i understood the problem you need to set the header. To allow this file to be read from other domains, it must contain the header to be: access-control-allow-origin:* This settings would be done on the server side where you wish to access the path. like: – Gaurav Sharma Aug 21 '17 at 17:02
  • Okay so I need to add the URL in header and then include it in the HTML using ng-include? – Phoenix Aug 22 '17 at 04:19