<html>
<script src="https://cdn.staticfile.net/angular.js/1.6.9/angular.min.js"></script>
<style>
input.ng-invalid {
background-color: pink;
}
input.ng-valid {
background-color: lightgreen;
}
</style>
<body ng-app="">
<p>请试着在输入框中输入内容:</p>
<form name="myForm">
<input name="myName" ng-model="myName" required>
</form>
<p>输入框需要填写内容,因此当你输入内容时,它会变成绿色。</p>
</body>
</html>