簡體   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