如何在angularjs的工具提示中显示ng-messages?

时间:2019-02-06 10:41:26

标签: javascript html angularjs

我试图添加一个工具提示,当我将鼠标悬停在其上方时,该提示会显示相应的ng消息。当我在html文件中运行此代码时,跨度字段根本不会显示。我想念什么?谢谢

    <form name="userForm" novalidate>
        <div class="form-group">
            <label>Name</label>
            <input type="text" name="name" class="form-control" 
                ng-model="main.name"
                ng-minlength="5"
                ng-maxlength="10"
                ng-pattern='/^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])([a-zA-Z0-9]+)$/'
                required>

            <div ng-messages="userForm.name.$error">
                <div ng-message="required">enter a name </div>
                <div ng-message="minlength">must be longer than 5</div>
                <div ng-message="maxlength">cannot exceed 10 characters</div>
                <div ng-message="pattern">must contain a combination of characters and numbers
                        <span class="fa fa-info-circle" data-toggle="tooltip" title="must contain a combination of characters and numbers"></span>
                </div>
            </div>
        </div>

        <div class="form-group">
            <button type="submit" class="btn btn-danger">Submit</button>
        </div>

    </form>
    <span class="fa fa-info-circle" data-toggle="tooltip" title="must contain a combination of characters and numbers"></span>

0 个答案:

没有答案