Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS Weird Behavior, NG-INCLUDE Causes Whole Page to Re-Load

A simple ng-include causes the page to recursively print out the whole site over and over in an area of the page, this causes the browser to crash. If I change the path the same thing happens so apparently it's not even looking at the path. If i use ng-include anywhere on the page the same weird behavior will happen.

The template (list.html) is in a sub-folder to where the angularjs scripts are.

HTML

<div ng-if="comments_data">

    <div ng-include="'templates/list.html'"></div>
</div>

Template

<li ng-repeat="comment in comments_data">
    {{ print_some_stuff }}
</li>
like image 603
user3704920 Avatar asked Oct 21 '25 13:10

user3704920


1 Answers

Can you please try:

<div ng-if="comments_data">
    <div ng-include="'/templates/list.html'"></div>
</div>

The slash at the beginning of the path was the issue for me. Check your router and see how templates are loaded (should be the same way with a leading slash).

like image 127
Konstantin Zlatkov Avatar answered Oct 24 '25 04:10

Konstantin Zlatkov