- I have a project that was developed with FLASK,Jinja2 templates. It is a simple webapp that allows user to login and see their online profile
- Currently I am trying to improve the project by adding in AngularJS&BootStrap for client-side, because I want to use ngMessages and some other angular dependencies
- The flask_wtf form submit button will work outside < html ng-app> tag but it doesn't work when I put the flask_wtf form inside < html ng-app> tag
- Update: Hello davidism, how is this a duplicate question when my issue is not related. Please note that I am not asking about how to fix the delimiter notation, not asking about how to use angularJS {{var}} inside Jinja2. I am trying to know if I could use flask_wtf inside the AngularJS < html ng-app> tag. As i tried to put the flask_Wtf form inside < html ng-app> tag and it doesnt work, it works outside the tag though.
form.py
class LoginForm(Form):
"""
For user to login.
"""
username = StringField(u'User Name:',validators=[
InputRequired(),
Regexp(ConfigRegex.RE_LOGIN_ID, message=ConfigRegex.RE_DESC_LOGIN_ID)])
passwd = PasswordField(u'Password:', validators=[
InputRequired(),
Regexp(ConfigRegex.RE_PASSWD, message=ConfigRegex.RE_DESC_PASSWD)])
submit = SubmitField(u'Log sIn')
login.html with flask_wtf (submit button is working)
<form method="POST">
{{ form.hidden_tag() }}{# Render any hidden fields, including the CSRF #}
<div class="field">{{ form.username.label }} {{ form.username }}</div>
{{ macros.show_field_errors(form.username.errors) }}
<div class="field">{{ form.passwd.label }} {{ form.passwd }}</div>
{{ macros.show_field_errors(form.passwd.errors) }}
<div class="field">{{ form.submit }}</div>
</form>
login.html with flask_wtf inside AngularJS < html ng-app> tag (submit button not working)
<html ng-app="loginApp">
////////////////////////////////////////////////////
//test form with flask (inside ng-app not working)
////////////////////////////////////////////////////
<form method="POST">
{{ form.hidden_tag() }}{# Render any hidden fields, including the CSRF #}
<div class="field">{{ form.username.label }} {{ form.username }}</div>
{{ macros.show_field_errors(form.username.errors) }}
<div class="field">{{ form.passwd.label }} {{ form.passwd }}</div>
{{ macros.show_field_errors(form.passwd.errors) }}
<div class="field">{{ form.submit }}</div>
</form>
///////////////// END //////////////////
<form name="editForm" method="post" id="login" class="form-signin" novalidate>
.....
.....
<span ng-class="{ 'has-error': editForm.password.$touched && editForm.password.$invalid }">
<div class="form-group input-group">
<input class="form-control" placeholder="Password" name="password" type="password" name='password' ng-model="password" g-maxlength="20" required>
</div>
<div class="help-block" ng-messages="editForm.password.$error" ng-if="editForm.password.$touched">
<p ng-message="required">Password is required</p>
<p ng-message="maxlength">Password is too long</p>
</div>
</span>
<button class="btn btn-lg btn-danger btn-block" type="submit" ng-disabled="!editForm.$valid">Login</button>
</form>
</html>