Angular form not working in a table

时光总嘲笑我的痴心妄想 提交于 2019-12-01 18:05:10
Pankaj Parkar

The way you are doing, will not render the html correctly on the page, because its invalid html as per table standards. Basically behind the scene html renderer will throw out this from out of the table tag while rendering the html on page. So for having form inside table tag, you could use ng-form attribute instead of having form element.

But by using ng-form directive you can't have ng-submit directive, you should submit a form via button only.

Html

<tr ng-form="myForm">
    <td>Add an item</td>
    <td><input type="text" name="name" id="newName" class="form-control" placeholder="Name" required ng-model="controller.add.name"></td>
    <td><textarea name="description" id="newDescription" class="form-control" placeholder="Description" ng-model="controller.add.description"></textarea></td>
    <td><button class="btn btn-xs btn-primary" type="button" ng-click="controller.add.save()">Add</button></td>
</tr>

For more detailed answer about structuring of table, you could refer this answer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!