<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<link rel="stylesheet" href="D:\Mano\Angular\Ex1\styles.css">
<body ng-app="myApp" ng-style="bColor">
<mano-directive>
</mano-directive>
<form name="myForm">
Email:
<input type="email" name="remail" ng-model="mail">
<span ng-show="myForm.remail.$error.email">Enter valid email</span>
<br>
<br> Valid: {{myForm.remail.$valid}}
<br> Dirty: {{myForm.remail.$dirty}}
<br> Touched: {{myForm.remail.$touched}}
<br> {{mail}}
<input type="button" ng-click="bColor={'background-color':'{{mail}}'}" value="Change Background"><!--mail variable not giving result--`enter code here`>
</form>
<script src="D:\Mano\Angular\Ex1\myApp.js"></script>
<script src="D:\Mano\Angular\Ex1\myCtrl.js"></script>
<script src="D:\Mano\Angular\Ex1\myDir.js"></script>
</body>
</html>
Angular JS--從文本框中獲取值並將其用於身體背景。 文本框的值應該在郵件變量進行同步,所以,當按鈕被點擊的值應該被用作身體背景顏色 請幫助Angular JS--從文本框中獲取價值並將其用於身體背景
您應該添加NG模式爲十六進制顏色:) – Disfigure