我有一个表格被移到表格中,失去了内置的表格验证功能,因为我不能使用 ng-submit:
<tr ng-form="controller.add.form">
<td>New 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="submit" ng-click="controller.add.save()">Save</button></td>
</tr>
这是我的控制器的样子:
.controller('ObjectController', ['ObjectService', function(ObjectService)
{
var objects = this;
objects.entries = [];
objects.add = {
name: '',
description: '',
save: function()
{
if(!objects.add.form.$valid) return;
ObjectService.create(
{name: objects.add.name, description: objects.add.description},
function(r)
{
if(r && 'name' in r)
{
objects.add.name = '';
objects.add.description = '';
objects.entries.push(r);
}
}
);
}
};
ObjectService.read({}, function(r) { objects.entries = r; });
}])
单击时如何使用标准弹出窗口进行保存方法触发验证?