【问题标题】:angularjs url together with django frameworkangularjs url 和 django 框架
【发布时间】:2016-01-27 08:51:31
【问题描述】:

我对 Angular 的 ng-click() 和重定向到新页面有一个小问题。问题来了:

在我的 html 中,我有一个带有属性的小型 d3 应用程序:

.attr("ng-click", "go(" + "'" + "{% url 'home' %}" + "'" + ")")

在我的 js 文档中:

$scope.go = function(link) {
    $location.path(link);
};

我的基本网址是这样的:

127.0.0.1:8000/username/test/

现在当我点击 d3 元素时,我得到以下信息:

127.0.0.1:8000/username/test/#home/

但我希望拥有:

127.0.0.1:8000/home/

您有解决此问题的提示吗?我也尝试了 $location.hash(...) 但没有运气...

【问题讨论】:

    标签: javascript angularjs django d3.js


    【解决方案1】:

    您可以使用$window 服务:

    .attr("ng-click", "$window.location.href = '{% url 'home' %}'")
    

    $location 用于需要留在同一个页面内的情况。

    【讨论】:

      猜你喜欢
      • 2014-01-14
      • 2015-03-23
      • 2019-02-20
      • 2016-12-15
      • 2014-03-15
      • 1970-01-01
      • 2015-06-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多