programing

Angularjs ng 반복 테이블 행이 작동하지 않는 경우 클릭

randomtip 2023. 3. 22. 23:00
반응형

Angularjs ng 반복 테이블 행이 작동하지 않는 경우 클릭

ng-click 다음 HTML이 Angular에서 작동하지 않습니다.JS

<tr ng-repeat="ai in alert_instances" ng-click="go('/alert_instance/{{ai.alert_instancne_id}}')">
  <td>{{ai.name}}</td>
  <td>{{ai.desc}}</td>
</tr>

현재 컨트롤러의 "Go" 기능은

$scope.go = function (hash) {
  console.log("hi")
};

당신은 그것을 잘못하고 있어요.Angular Angular directive)에서는.ng-click이 구문은 템플릿용입니다.

적절한 방법:

<tr ng-repeat="ai in alert_instances" ng-click="go(ai)">
  <td>{{ai.name}}</td>
  <td>{{ai.desc}}</td>
</tr>

$scope.go = function(ai) {
  var hash = '/alert_instance/' + ai.alert_instancne_id;
  //...
};

언급URL : https://stackoverflow.com/questions/15288047/angularjs-ng-click-on-repeat-table-row-not-working

반응형