this seems like a simple problem but it has taken hours of mine .
I've the following code.
<div class="row grid" id="draftRow{{$index}}" ng-repeat="draft in drafts">
<div class="col-md-7 cell" ng-bind="draft.getTitle()"></div>
<div class="col-md-2 cell center" ng-bind="draft.getUserName()"></div>
<div class="col-md-2 cell center" ng-bind="draft.getDate()"></div>
<div class="col-md-1 cell center" >
<span class="gridbutton" ng-click="editPost(draft.getPostID())">edit</span>
|
<span class="gridbutton" ng-click="deletePost(draft.getPostID(),'{{$index}}')">delete</span>
</div>
</div>
The deletePost function is not being called onclick although I can see deletePost(draft.getPostID(),'0')
written on browser inspect element. What is the problem here can anyone point out ? If I remove the second parameter of the deletePost function everything runs fine .
I've also tried $parent.$index
, that calls the function but doesn't output the rowIndex
on inspect element.
正如我在评论中所说:不使用{{...}}
进行解释,只需使用变量本身: deletePost(draft.getPostID(), $index)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.