Forms 如何在AngularJs中获得切换所需的消息?

Forms 如何在AngularJs中获得切换所需的消息?,forms,validation,angularjs,Forms,Validation,Angularjs,我正在尝试根据条件设置必填字段。这是我的密码 <div id= 'outer-form' ng-form='main' validate-on-submit='#page-errors' on-invalid='DisplayErrors();' on-valid="SubmitPage();'> ...other div's <div ng-repeat='myItem in aFunction.myItemArray' ng-form='sub'> <

我正在尝试根据条件设置必填字段。这是我的密码

<div id= 'outer-form' ng-form='main' validate-on-submit='#page-errors' on-invalid='DisplayErrors();' on-valid="SubmitPage();'>
...other div's

<div ng-repeat='myItem in aFunction.myItemArray' ng-form='sub'>
    <div ng-show= 'myType == "Shoes"'>
        @Html.TextBox('Shoes', null, new { ng_model = 'Shoes', ng_required = 'myType == "Shoes"' })
        <span ng-show="sub.Shoes.$error.Text">Shoes required</span>
    </div>

    <div ng-show= 'myType == "Socks"'>
        @Html.TextBox('Socks', null, new { ng_model = 'Socks', ng_required = 'myType == "Socks"' })
        <span ng-show="sub.Socks.$error.Text">Socks required</span>
    </div>
    <button class="clientContinue" id="step-submit-btn">CONTINUE</button>
</div>

我不知道您在示例中使用的是什么样的模板引擎,但是如果它支持根据布尔值添加属性,那么您的代码看起来是正确的

说到Angular,看起来您需要一个自定义验证器(类型验证器),在这里您可以将类型作为HTML属性传递。在验证程序中,您将能够非常轻松地控制所需的标志


您可以在以下链接中找到有关自定义验证器的更多信息:

此模板引擎是什么?你能用纯html显示代码吗?