0
我正在使用Nunjucks渲染模板加班時點擊正確的URL。這是一塊模板:在angularJS腳本中使用模板變量?
<h3>Select some text </h3>
<div ng-app="myApp">
{% for i in result %}
<div id={{i._id}} class="task" commentId = {{i._id}} get-popover-content> {{i.text}} </div> <br/>
{% endfor %}
我也把一個角JS腳本在此模板,現在,我只是想弄清楚什麼是傳遞變量的最好辦法{{我._id}}要在指令內使用(可能,我想這i._id發送到我的數據庫來獲取信息
<script>
var app = angular.module("myApp", []);
app.directive("getPopoverContent", function($http) {
return {
link: function(scope, element, attr) {
element.popover();
$(element).on('mouseover', function(e){
console.log('i._id = ',{{i._id}});
})
})
} }});
- 這是使用模板引擎+ angularJS的正確方法嗎?
- 有沒有辦法做到這一點?
我已經試過像這樣的: VAR app = angular.module(「myApp」,[]); ();'mouseover',function(e){ console();();(mouseover),function(e){ console.datctive(「getPopoverContent」,function(){ function link(scope,element,attrs){ .LOG(scope.commentId); 的console.log(attrs.commentId); }) } 返回{ 鏈接:鏈接, 限制: 'A', 範圍:{ commentId: '= commentId' } } }); 只是爲了檢查,但它沒有奏效。我得到的是commentId是未定義的...任何線索@dangh –