angular 1.5组件回调函数参数传递

时间:2018-01-30 23:41:49

标签: angularjs components

如何将行对象传递给回调函数组件。

commonGridComponent:

.component('commonGridComponent', {
  templateUrl: 'public/templates/commonGridComponent.tpl.html',
 bindings: {
options: '=', 
headersList: '<', 
gridData: '=',
gridCallBack: '&'
},
 controller: 'commonGridController',
controllerAs:'vm'
   });

commonGridController:

.controller('commonGridController', ['$scope', function ($scope) {
     var vm = this; // jshint ignore:line
     }]);

commonGridComponent.tpl.html:

<tbody>
<tr ng-repeat="rowData in vm.gridData">
<td  ng-repeat="(key, value) in rowData" ng-click="vm.gridCallBack(rowData)">{{value}}</td>
</tr>
</tbody>

父html:

 <common-grid-component options="xx" headers-list="xx", grid-data="vm.data" grid-call-back="vm.onSelectRow()"></common-grid-component>

父控制器:

vm.onSelectRow= function (rowData){
console.log("onSelectRowonSelectRowonSelectRow", rowData);
};

我到这里的行数据是未定义的。请建议我

0 个答案:

没有答案