我正在尝试在角度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%},但是没有用。
您已在h1
标记中呈现{{selectedUserId}},因此在您的ng-repeat中您还应使用{{ selectedUserId }}
:
<div data-ng-repeat="profile in profiles | filter:{ userId: '{{ selectedUserId }}' }: true">