Le *_*der 9 history.js angularjs
我的代码工作直到我开始使用ng-include.现在,每次我去一个使用该指令的页面时,我都会卡在页面上.后退按钮已停止工作,您将永远停留在同一页面的循环中.
我的网站运行Asp.NET MVC 5.
我的一些代码:
HTML"主机"
<div id="place">
<div data-ng-include="'/app/angular/views/place.html'"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
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;
});
});
Run Code Online (Sandbox Code Playgroud)
当我删除ng-include并用"原始"HTML替换它,它工作正常.这种"无限循环"只在ng-include添加时才会发生.
这个问题我曾经遇到过一次,看来是Html5模式的问题。
尝试将其添加到您的应用程序配置中:
$locationProvider.html5Mode(false);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
603 次 |
| 最近记录: |