简体   繁体   English

Angular:条件字段不适用于服务器端

[英]Angular: Conditional field doesn't work with server side

i have a conditional field like this : 我有这样一个条件字段:

<form ng-app="myApp" name="frm">
    <select ng-model="NewBranchRequest.BranchTypeCode">
        <option selected="selected" value="0">third</option>
        <option value="1">first</option>
        <option value="2">second</option>
    </select>
    <input class="ng-pristine ng-valid" type="text" name="power" ng-model="NewBranchRequest.PwrCnt" placeholder="sad" ng-required="NewBranchRequest.BranchTypeCode==0">
          <span style="color:red" ng-show="frm.power.$invalid">
                *
            </span>
    <button>Submit</button>
</form>  

Demo 演示
it works, but option fill from server and it doesn't work. 它可以工作,但是服务器中的选项填充无效。

UPDATE UPDATE
Check This Demo which is not working . 检查此演示不起作用。

All i want is after select Bug in select list, input get rquired . 我想要的只是在选择列表中的错误之后,输入rquired。

Any idea ? 任何想法 ?

In http://jsfiddle.net/sadeghbayan/MTfRD/1452/ http://jsfiddle.net/sadeghbayan/MTfRD/1452/

change 更改

ng-required="form.type==0"  

to

ng-required="form.type=='bug'"

I made the changes here: http://jsfiddle.net/MTfRD/1453/ 我在这里进行了更改: http : //jsfiddle.net/MTfRD/1453/


In addition, if you want to get the json object in form.type you can change this 另外,如果要以form.type获取json对象,则可以更改此设置

ng-options='option.value as option.name for option in typeOptions'

to

ng-options='option.value for option in typeOptions'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM