使用ng-if,获取不到里面的ng-model值,解决方案

当使用ng-if时,是会把默认作用域删除的,当其为true时,只是增加了其界面元素,为最原始状态,控制器在其上是不起作用的,要想获取ng-if中的值,可以用$scope.$$childTail.layername。

<div ng-if="serviceVirson!=1" class="form-inline">
        <label style="color:red">*</label><label class="modal-message">名称 :</label>
        <input required class="form-control sys_input" type="text"  ng-model="layername" placeholder="" maxlength="15"/>
    </div>

  

原文地址:https://www.cnblogs.com/bobo-show/p/5053797.html