2013-09-28 23 views
1

我在我的模板中使用angular1.1.5和ngInclude。每當我加載頁面,我會得到hashbang後的重複路徑:http://localhost/home#/home,http://localhost/account#/account,等等。當頁面中有ngInclude指令(我認爲這也發生在ngView)時會發生這種情況。我沒有使用這個應用程序的任何路由,這是一個非常簡單的整體設置。Angular 1.1.5 url使用ngInclude時重複

在模塊配置中使用$locationProvider.html5Mode(true)似乎解決了這個問題,但我不想使用它,因爲它不適合這個應用程序的設計。

這似乎沒有發生在角1.2.0-RC.2中,但我不想遷移。任何已知的解決方法?謝謝。

回答

0

使用功能的值:

app.controller("foo", function($scope) { 

$scope.url = function() { 
    return "/bar"; 
    } 
}); 


<div ng-controller="foo"> 
    <ng-include src="url()"></ng-include> 
</div>