如何在ng-repeat过滤器中传递HoDjango views.py上下文数据变量

问题描述 投票:1回答:1

我正在尝试在角度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)

我的重复

<div data-ng-repeat =“个人资料中的个人资料|过滤器:{userId:selectedUserId}:true”>

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

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

javascript python django angularjs
1个回答
0
投票

您已在h1标记中呈现{{selectedUserId}},因此在您的ng-repeat中您还应使用{{ selectedUserId }}

<div data-ng-repeat="profile in profiles | filter:{ userId: '{{ selectedUserId }}' }: true">
© www.soinside.com 2019 - 2024. All rights reserved.