我的代碼一直在工作,直到我開始使用ng-include
。現在,每當我去使用這個指令的頁面時,我都會被卡在頁面上。後退按鈕已停止工作,並且您永遠停留在同一頁面的循環中。AngularJS ng-include do HistoryJS停止工作
HTML 「主機」
<div id="place">
<div data-ng-include="'/app/angular/views/place.html'"></div>
</div>
HTML place.html
:我的網站與Asp.NET MVC 5.
我的代碼的某些位運行
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;
});
});
當我刪除了ng-include
並用 「原始」 HTML取代它,它工作正常。這個「無限循環」僅在添加ng-include
時發生。
我想你應該展示你如何使用'ng-include'指令,並且如果你正確地使用它,你應該提供一個能夠重現問題的重調器。 – Stewie
您應該將任何外部插件轉換爲Angular指令,爲DOM操作混合兩個不同的範例並不明智。 –
我無法想象任何人這樣做。如果它是一個簡單的插件,我會同意你的看法,但是,**任何插件......它太重了,你不覺得嗎? –