I have an html on which if I put 'color' in the input box, the paragraph must have red background. I think I am using ng-class properly, still not able to get it red. Can someone help?
HTML:
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<style>
.red: {background:red}
</style>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<p ng-class="{'red':entry=='color'}"> This is box. </p>
<input ng-model="entry" />
<script>
//Module Declaration
var app = angular.module('myApp',[]);
//Controller Declaration
app.controller('myCtrl',function($scope){
$scope.entry = "";
});
</script>
</body>
</html>
The mistake is in your CSS: there is a superfluous :
after .red
.
The correct declaration is:
.red {background:red}