Javascript ng单击“不在jinja2模板中工作”
我试图在函数Javascript ng单击“不在jinja2模板中工作”,javascript,angularjs,jinja2,Javascript,Angularjs,Jinja2,我试图在函数getMenuById({{restaurant.id}},{{{restaurant.name}}')中传递jinja变量。但在页面呈现ng后,单击不工作。我尝试在控制台上打印,但没有成功。下面是Jinja模板文件,我在ng click中传递Jinja变量,并且我用方括号([[])更改了角度插值符号 restaurant.html {% for restaurant in restaurant_details %} <div class="col-md-12" ng-if="
getMenuById({{restaurant.id}},{{{restaurant.name}}')
中传递jinja变量。但在页面呈现ng后,单击不工作。我尝试在控制台上打印,但没有成功。下面是Jinja模板文件,我在ng click
中传递Jinja变量,并且我用方括号([[])更改了角度插值符号
restaurant.html
{% for restaurant in restaurant_details %}
<div class="col-md-12" ng-if="serverSideRender">
<article class="box">
<figure class="animated fadeInRight" data-animation-type="fadeInRight" data-animation-delay="0.3" style="animation-duration: 1s; animation-delay: 0.3s; visibility: visible;">
<a class="hover-effect" title="" href="/restaurant/{{restaurant.id}}">
<img class="img-responsive" alt="" src="{{restaurant.images[0].image_url}}">
</a>
</figure>
<div class="details">
<div class="pull-right rating-container">
<strong>{{ restaurant.rating }}
<i class="fa fa-star" aria-hidden="true"></i>
</strong>
</div>
<h2 class="box-title" style="font-size:24px">
<strong>
<a href="/restaurant/{{restaurant.id}}">{{ restaurant.name }}</a>
</strong>
</h2>
<div>
<small>
<strong> {{restaurant.city}} </strong>
</small>
</div>
<div class="restaurant-address">
{{restaurant.address}}
</div>
<div class="restaurant-details">
<span class="detail-title">Cuisines : </span>
{% for association in restaurant.association %}
<span>
<strong>{{association.cuisines.cuisine}} {% if loop.index != restaurant.association|length
%}
<span>,</span>
{% endif %}
</strong>
</span>
{% endfor %}
</div>
<div class="restaurant-details">
<span class="detail-title">Cost for two : </span>
<span>
<strong>₹ {{restaurant.price}}</strong>
</span>
<!-- <span ng-repeat="association in restaurant.association">
<strong>association.cuisines.cuisine]] <span ng-if="$index != restaurant.association.length - 1" >,</span></strong>
</span> -->
</div>
<div class="btn-group btn-group-justified">
<a href="tel:{{restaurant.phone}}" class="btn btn-primary">
<i class="fa fa-phone" aria-hidden="true"></i> call</a>
<div class="btn btn-default" ng-click="getMenuById('{{restaurant.id}}', '{{restaurant.name}}')">
<i class="fa fa-file-text-o" aria-hidden="true"></i> view menu
</div>
</div>
</div>
</article>
</div>
{% endfor %}
如果您只是将{{restaurant.id}}
放入
标记中,它会填充吗?@mmenschig jinja转换为它的值<代码>{{restaurant.id}
给我一个id值,它是15。你能通过这个过程创建一个游乐场吗isse@SaEChowdary建议任何游乐场。在google上找不到。plunker,JSFIDLE
$scope.getMenubyId = function (restaurantId, restaurantName) {
$scope.restaurantName = restaurantName;
$http.get("/api/v1/restaurant/dish?restaurant_id=" + restaurantId)
.then(function (res) {
$scope.restaurantDish = res.data.result.dish;
},
function (err) {
console.log(err);
})
}