Home > Web Front-end > JS Tutorial > body text

AngularJS's ng-click parameter passing method

陈政宽~
Release: 2018-05-30 14:51:24
Original
6233 people have browsed it

This article mainly introduces the ng-click parameter passing method of AngularJS. The editor thinks it is quite good. Now I will share it with you and give it as a reference. Let’s follow the editor to take a look.

I encountered a problem today, which is the ng-click parameter transmission problem. I found a lot of information on the Internet, so I left a note first

<ul id="dataSet" ng-repeat="item in infos" ng-model="dataSet">
  <li ng-click="sentOutQuery(&#39;{{item.detailId}}&#39;)" >
    <p class="voucherLeft">
      <p class="p1">{{item.transAmount}}</p>
      <p class="p2">已分配:<span >{{item.usePoints}}</span></p>
    </p>
    <p class="voucherRight">
      <p class="p3">授信方:<span>{{item.rollOutAccountName}}</span></p>
      <p class="p4">授信日期:<span>{{item.createTime}}</span></p>
    </p>
  </li>
</ul>
Copy after login
//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=&#39;sentOutQuery.html&#39;;
}
Copy after login

ng-click=" sentOutQuery('{{item.detailId}}')" In this way, although the debugger can see the passed parameter value on the page, the event click is invalid, as shown below;

Only by directly introducing the parameters in the click event can the parameters be obtained in the corresponding JS code

The above is the detailed content of AngularJS's ng-click parameter passing method. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template