Skip to content

Instantly share code, notes, and snippets.

@guyoun
Created November 4, 2015 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guyoun/005eeafd6873d849df21 to your computer and use it in GitHub Desktop.
Save guyoun/005eeafd6873d849df21 to your computer and use it in GitHub Desktop.
Adding attributes of the angularjs to a field of wtform
<form name="confirm_form" method="post" action="{{ url_for('auth.process_confirm') }}" class="col-md-offset-3 col-md-6">
    {{ form.hidden_tag() }}

    {% if form.password %}
        {{ render_field(form.password, class_='form-control', label_class='sr-only',  placeholder='비밀번호', size=30, addon='fa fa-lock fa-lg',
                        required=True, **{'ng-model': "credentials.password", 'ng-keyup': "check_strength(credentials)"}) }}
    {% endif %}

    <div class="form-group" ng-if="strength_result">
        <span class="{{strength_result.message.style | angular}}">{{strength_result.message.text | angular}}</span>
    </div>

    {% if form.password2 %}
        {{ render_field(form.password2, class_='form-control', label_class='sr-only',  placeholder='비밀번호', size=30, addon='fa fa-lock fa-lg',
                        required=True, **{'ng-model': "credentials.password2"}) }}
    {% endif %}

    {{form.token}}

    <p class="text-center">
        <button type="submit" class="btn btn-primary" ng-disabled="!confirm_form.$valid">저장</button>
    </p>
</form>
  • macro를 새로 정의하기 귀찮아서 **{'ng-model': "credentials.password", 'ng-keyup': "check_strength(credentials)"으로 angularjs 속성 추가
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment