繁体   English   中英

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

[英]How can I pass HoDjango views.py context data variable in ng-repeat filter

我正在尝试在有角度的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">

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM