我正在尝试在有角度的ng-repeat中使用过滤器,其中selectedUserId是context_dict变量。
我的角冰壶是{-}

我的view.py-从网址获取user_id

def profile(request, user_id): context = RequestContext(request) context_dict = {} context_dict['selectedUserId'] = user_id return render_to_response('rango/profile.html', context_dict, context)

我的重复



    <h1>{{ selectedUserId }} Profile<h1>
    <h2>{- profile.userId -}</h2>


如何获取我的selectedUserId进行渲染,我尝试了{%selectedUserId%},但是没有用。

最佳答案

您已经在h1标签中渲染了{{selectedUserId}},因此在ng-repeat中还应该使用{{ selectedUserId }}

<div data-ng-repeat="profile in profiles | filter:{ userId: '{{ selectedUserId }}' }: true">

关于javascript - 如何在ng-repeat过滤器中传递HoDjango views.py上下文数据变量,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27561608/

10-12 00:09