0

我为验证消息定义了一个模板:

<script type="text/ng-template" id="my-custom-messages">
  <div ng-message="required">blah-blah</div>
</script>

这是我的表格:

<form name="myForm">
    <input type="text" name="myEmail" ng-model="email" required />
    <button ng-click="submit()"></button>
</form>

现在我想访问控制器中的验证消息,如下所示:

$scope.submit = function() {
    for (var i = 0; i < $scope.myForm.$error.required.length; i++) {
        var err = $scope.myForm.$error.required[i];
        /// how to get validation message ?
    } 
}

可能吗 ?

4

0 回答 0