Hi I have following html
<tbody ng-repeat="c in forms">
<tr>
<td> <input type="text" ng-model=c.name /> </td>
<td> <input type="text" ng-model=c.ac /> </td>
</tr>
<tr ng-repeat="a in c.te">
<td> <input type="text" ng-model=a.name /> </td>
<td> <input type="text" ng-model=b.ac /></td>
</tr>
</tbody>
<button ng-click="add(c)">Add</button>
<button ng-click="submit(c)">Crate account</button>
In my controller
$scope.forms = [{
"name" : "form1", "ac": 251
}, {
"name": "form2", "ac": 252
}, {
"name": "form3", "ac": 253
}];
$scope.addRows = function (c) {
alert(form);
if (typeof c.te == 'undefined') {
c.te = [];
}
alert("pushing");
c.te.push({ name: '', ac: ''});
};
I keep getting error at if (typeof c.te=='undefined') saying
Error: c is undefined
Please let me know what is wrong here. The if statement is supposed to check if it is undefined, but it doest work Thanks