Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
change css2
<!doctype html>
<html lang="en" ng-app>
<meta charset="UTF-8">
.error {
background-color: red;
.warning {
background-color: yellow;
<div ng-controller="HeaderController">
<div ng-class='{error: isError, warning: isWarning}'>{{messageText}}</div>
<button ng-click='showError()'>Simulate Error</button>
<button ng-click='showWarning()'>Simulate Warning</button>
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript" src="main.js"></script>
function HeaderController($scope) {
$scope.isError = false;
$scope.isWarning = false;
$scope.showWarning = function() {
$scope.isError = false;
$scope.isWarning = true;
$scope.messageText = 'this is a warning';
$scope.showError = function() {
$scope.isError = true;
$scope.isWarning = false;
$scope.messageText = 'this is a error';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.