2

I´m trying to include a HTMl page with the ng-include directive into a div in my Main HTML.

Main HTML:

<div class="col-sm-9" data-ng-include="'subPage.html'">
    </div>

This SubPage is displayed correclty in the given div. Additionaly the subPage contains a script which contains some angular methods. Which i Added in the Header of SubPage.

<script type="text/javascript" src="js/subService.js"></script>

Calling the Page with

localhost:8080/subPage

Allowes me to use all functions and linked functions from the controller.

But when included via ng-include the Script will not even load which ofc results in no functionality. (checked in console)

Both MainPage and SubPage contain a ng-app directive and are both full standalone HTML.

Does anyone have a idea how to do this?

UPDATE

Like said in the answers

<object name="subPage" type="text/html" data="./subPage.html"></object>

Is a solution.But I did´t found a solution to swap them dynamcly in my body div tag.

Another Option is to load via Jquery:

$("#subpage_id").click(function() {
        $.getScript("js/subService.js"); 
        $("#body").load("./subPage.html");

    });

This solution loads the HTMl and Styles but wont any js (which is dumb because it wont load my controller js)

Cœur
  • 37,241
  • 25
  • 195
  • 267
Offset
  • 609
  • 1
  • 5
  • 22
  • 3
    check this once http://stackoverflow.com/questions/20087274/how-can-i-load-javascript-file-along-with-ng-include-template – Sa E Chowdary Nov 10 '16 at 11:51
  • okay thanks alot. This looks like a reasonable solution but why take the fuzz? Tested this quick and worked. – Offset Nov 10 '16 at 12:08

0 Answers0