在angular已加载所有内容后评估angularjs ng-click参数

时间:2014-07-08 11:43:57

标签: javascript angularjs

我有一个简单的玉标记 -

.well(ng-repeat="note in notes")
            .row
                h3.pull-left {{note.title}}
                p.pull-right ( {{note.subject}}, {{note.college}} )
            .row.margin-bottom-10(style="border-bottom: 1px solid #000")
                p.pull-left Author: {{note.author}}
                p.pull-right Uploaded by: {{note.uploader}}
            .row
                p.
                    {{note.description}}
            .row
                button.btn.btn-default.pull-left(ng-click="download('{{note.noteId}}','all')") Download
                button.btn.btn-default.pull-right Details

现在这会在我的网站中转换为以下html -

<div ng-repeat="note in notes" class="well ng-scope">
   <div class="row">
      <h3 class="pull-left ng-binding">test</h3>
      <p class="pull-right ng-binding">( test, MSRIT )</p></div>
   <div style="border-bottom: 1px solid #000" class="row margin-bottom-10">
      <p class="pull-left ng-binding">Author: test</p>
      <p class="pull-right ng-binding">Uploaded by: harshitladdha93@gmail.com</p></div>      
   <div class="row">
      <p class="ng-binding">test</p></div>
   <div class="row">
      <button ng-click="download('5f4815f2-73a9-4621-86ed-b4e302cc49ba','all')" class="btn btn-default pull-left">Download</button>
      <button class="btn btn-default pull-right">Details</button></div></div>

所以我在这里看到的是{{note.noteId}}在我的"5f4815f2-73a9-4621-86ed-b4e302cc49ba"函数中转换为ng-click="download()" 但是在我的控制器中,如果我尝试 -

$scope.download = function(noteId,fileId){
      var url = '/download/' + noteId + '/' + fileId;
};

我得到了

/download/{{note.noteId}}/all

{{note.noteId}}而不是由angular处理的值 我应该如何解决这个问题

1 个答案:

答案 0 :(得分:0)

从jade模板中删除包裹在note.noteId周围的花括号{{}},以使其正常工作,这样就可以了:

button.btn.btn-default.pull-left(ng-click="download(note.noteId,'all')") Download