首页 > ng-show 表达式动态显示

ng-show 表达式动态显示

form input输入框
点击搜索框显示提示内容,点击其他地方,提示内容消失

代码见下

<form class="form-horizontal" name="checkForm">
    <div class="form-group">
        <label class="col-sm-3 control-label">用 户 名</label>
        <div class="col-sm-8 account">
            <input type="text" class="form-control showHide" placeholder="您的账户名和登录名"
                ng-model="account"
                name="account"
                required="required"
                ng-pattern="regularList.account"
                ng-blur="checkForm.account.$blured = true;"
                ng-focus="checkForm.account.$blured = false;"
                autocomplete="off"/>
            <span ng-class="{'right':(checkForm.account.$error.pattern),'error':checkForm.account.$valid}"></span>
        </div>
    </div>
    <div class="tip-container"  ng-show="checkForm.account.$blured">
        <div class="input-tip">
            <i></i>
            <span>!支持中文、字母、数字、“-”“_”的组合,4-20个字符</span>
        </div>
    </div>
</form>

具体效果见下

当我点击搜索框时,提示内容显示

求指导,谢谢


ng-blur和ng-focus的表达式写反了吧?还有变量里边有必要加入$blured么?随便一个变量都能标记是否获得焦点吧,你再看看。

【热门文章】
【热门文章】