时间:2021-02-15 10:23:53 | 栏目:AngularJS | 点击:次
今天遇到个难题就是ng-click传参问题,在网上找了好多资料,先留个笔记
<ul id="dataSet" ng-repeat="item in infos" ng-model="dataSet"> <li ng-click="sentOutQuery('{{item.detailId}}')" > <div class="voucherLeft"> <p class="p1">{{item.transAmount}}</p> <p class="p2">已分配:<span >{{item.usePoints}}</span></p> </div> <div class="voucherRight"> <p class="p3">授信方:<span>{{item.rollOutAccountName}}</span></p> <p class="p4">授信日期:<span>{{item.createTime}}</span></p> </div> </li> </ul>
//js代码 $scope.sentOutQuery = function(sourceDetail){ var expiresDate= new Date(); expiresDate.setTime(expiresDate.getTime() + 2*1000); $cookieStore.put("sourceDetailId", sourceDetail,{expires : expiresDate}); console.log(sourceDetail); window.location.href='sentOutQuery.html'; }
ng-click="sentOutQuery('{{item.detailId}}')" 这样虽然在页面上debugger能看到传的参数值,但是这样事件点击无效,如下图;
只有将点击事件中的参数直接引入才能在对应的JS代码中获取该参数