常用的方法,簡單的表單驗證由控制器觸發
//submit後觸發驗證
$scope.validateByManual = function(form) {
logger.debug('validate');
angular.forEach(form, function (control, name) {
// Excludes internal angular properties
if (typeof name === 'string' && name.charAt(0) !== '$') {
logger.debug('field name:' + name);
// To display ngMessages
control.$setTouched();
control.$setDirty();
// Runs each of the registered validators
control.$validate();
}
});
}
沒有留言:
張貼留言
留個話吧:)