My code was working until I started using ng-include
. Now, everytime I'll go to a page that uses this directive, I'm getting stuck on the page. The back button has stopped working and you stay forever in a loop of the same page.
My website is running with Asp.NET MVC 5.
Some bits of my code:
HTML "host"
<div id="place">
<div data-ng-include="'/app/angular/views/place.html'"></div>
</div>
HTML place.html
<div>
<h1>{{place.PlaceName}}</h1>
<ul class="unstyled-list">
<li data-ng-repeat="hint in place.Hints">
<!-- more code -->
</li>
</ul>
</div>
JAVASCRIPT
$scope.place = { };
// 'maps' is a google maps plugin
maps.autoComplete({ success: function(result) {
// gets the result of the user search
History.pushState({ name: result.name, id: result.id }, result.name, '/place/' + result.id);
});
History.Adapter.bind(window, 'statechange', function () {
var state = History.getState();
// go to the server and get more info about the location
$mapService.getMetaInfo({id: state.data.id}).then(function (d) {
// get place info
$scope.place = d;
});
});
When I remove the ng-include
and replace it with the "raw" html, it works fine. This "infinite loop" happens only when ng-include
is added.
ng-include
directive, and in case you're using it properly, you should provide a plunker that reproduces the problem. – Axial'/app/angular/views/place.html'
is wrong. If you are serving from '/app/' then you should trim that part of the path from your ngInclude usage. – Ebro