我要的是这样的: https://github.com/PatrickO10/meetUp如何显示一些通知,当输入不正确,并隐藏在输入正确
当你按下注册,你可以看到一些红色的音符。
他的代码在这里: https://github.com/PatrickO10/meetUp/blob/master/index.html#L95-L106 我试图自己写,但一直失败,不知道原因。我是这个领域的新人,你能帮我写吗?谢谢! 这是我简单的代码来测试这个部分: https://plnkr.co/edit/OL1QuesgZpqeEKoYS5cF?p=preview
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
</head>
<body>
<form name=signUpForm>
<label for="name">
<span>name:</span>
<input type="text" id="nameInput" name="nameInput" class="form-control" placeholder="your name" required autocomplete="name" autofocus ng-model="nameModel">
<div class="input-error" ng-message="signUpForm.nameInput.$error" role="alert" ng-if="signUpForm.nameInput.$touched">
<div ng-message="required">
<p>Input your name please!</p>
</div>
</div>
</label>
</form>
</body>
</html>
将ng-app,ng-controller放置在您的模板中。没有ng-app,angular将不会引导你的模板。 ng-model,ng-if只能在角度引导应用程序之后才起作用 –
但是在我添加ng-app之后,它不起作用,输入后便不会消失。 – fourth