Javascript AngularJS组件-函数绑定
我编写了一个表组件:Javascript AngularJS组件-函数绑定,javascript,angularjs,components,Javascript,Angularjs,Components,我编写了一个表组件: <table ng-model="$ctrl.model" class="table" md-progress="promise"> <thead class="thead"> <tr> <th class="theader">ID</th> <th class="theader">A</th> <th class="theade
<table ng-model="$ctrl.model" class="table" md-progress="promise">
<thead class="thead">
<tr>
<th class="theader">ID</th>
<th class="theader">A</th>
<th class="theader">Actions</th>
</tr>
</thead>
<tbody>
<tr md-row ng-repeat="row in $ctrl.data track by $index">
<td width="15%" class="trow">{{row.id}}</td>
<td width="15%" class="trow">{{row.a}}</td>
<td width="15%" class="trow">
<md-button ng-click="$ctrl.edit({x: row.id, y: row.a})"></md-button>
</td>
</tr>
</tbody>
我将新组件称为:
.component('tablesample', {
require: {},
templateUrl: 'Components/templates/tableSample.html',
bindings: {
data: '=',
model: '=',
edit: '&',
},
controller: function ($log) {
var tbl = this;
tbl.$onInit = function () {
};
tbl.$onChanges = function () {
};
}
})
<tablesample data="tableData" model="selectedRow" edit="editFunction()"></tablesample>
日志语句总是显示“undefined”,我不知道为什么,row.id会被填充,如果我转储它,我会看到1、2、3等等。。。。在editFunction中,我执行http get,因此如果x未定义,调用将失败
有人能看出我做错了什么吗
谢谢
我不得不改变:
<tablesample data="tableData" model="selectedRow" edit="editFunction()"></tablesample>
致:
谢谢
多克穆尔
<tablesample data="tableData" model="selectedRow" edit="editFunction()"></tablesample>
<tablesample data="tableData" model="selectedRow" edit="editFunction(id,a)"></tablesample>