有人可以解释下面的代码吗,我是棱角分明的新人请帮助我:
{% if validation_error %}
<div>{{ validation_error }}</div>
{% endif %}
在网页上:
完整代码:
<form name="login" method="POST" action="/app/login">
<div class="form-container">
<fieldset class="form-group">
<input class="form-control form-control-sm text-uppercase" id="username" name="username" type="text" placeholder="Username">
<input class="form-control form-control-sm" name="password" type="password" placeholder="Password">
</fieldset>
<button class="btn btn-primary btn-sm btn-block">signin</button>
{% if validation_error %}
<div class="small text-danger m-t-1">{{ validation_error }}</div>
{% endif %}
</div>
</form>
答案 0 :(得分:0)
将ng-show
标记添加到div
<div ng-show="login.username.$invalid && !login.username.$pristine" class="small text-danger m-t-1">You name is required.</div>
答案 1 :(得分:0)
您可以使用带有表单的角度验证和输入&#39;名称;
<form name="login" method="POST" action="/app/login">
<div class="form-container">
<fieldset class="form-group">
<input class="form-control form-control-sm text-uppercase" id="username" name="username" type="text" placeholder="Username">
<input class="form-control form-control-sm" name="password" type="password" placeholder="Password">
</fieldset>
<button class="btn btn-primary btn-sm btn-block" ng-disabled="!login.$valid">signin</button>
<div ng-if="!login.$valid" class="small text-danger m-t-1">form not valid</div>
<div ng-if="!login.username.$valid" class="small text-danger m-t-1">username not valid</div>
</div>
</form>
更多信息:https://www.w3schools.com/angular/angular_validation.asp
答案 2 :(得分:0)
答案 3 :(得分:0)
这是twig模板语法。
示例:强>
<!DOCTYPE html>
<html>
<head>
<title>My Webpage</title>
</head>
<body>
<ul id="navigation">
{% for item in navigation %}
<li><a href="{{ item.href }}">{{ item.caption }}</a></li>
{% endfor %}
</ul>
<h1>My Webpage</h1>
{{ a_variable }}
</body>
</html>