1

我在模板中使用带有 ngInclude 的 angular 1.1.5。每当我加载页面时,我都会在 hashbang: http://localhost/home#/homehttp://localhost/account#/account等之后得到一个重复的路径。当ngInclude页面中有指令时会发生这种情况(我认为这也发生在ngView)。我没有在这个应用程序中使用任何路由,总体而言这是一个非常简单的设置。

在模块配置中使用$locationProvider.html5Mode(true)似乎可以解决这个问题,但我不想使用它,因为它并不真正适合这个应用程序的设计。

这似乎不会发生在 Angular 1.2.0-RC.2 中,但我还不想迁移。任何已知的解决方法?谢谢。

4

1 回答 1

0

使用函数作为值:

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

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


<div ng-controller="foo">
  <ng-include src="url()"></ng-include>
</div>
于 2014-12-20T04:04:40.187 回答