Deadpool
Deadpool

Reputation: 8240

Changing background of body on click - AngularJS

I am using Angular.js to change background of body on click of a button. All seems fine but still program not running.

HTML:

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
</head>
<body data-ng-app="" data-ng-style="alpha"> 
<button data-ng-click="alpha={background:'red'}">Click Me</button>
</body> 
</html>

Reference:

https://docs.angularjs.org/api/ng/directive/ngStyle

Upvotes: 0

Views: 34

Answers (1)

ranakrunal9
ranakrunal9

Reputation: 13558

I think you have to try by removing "data-" from your attributes name as per jsfiddle

    `http://jsfiddle.net/56512rmc/2`

Upvotes: 1

Related Questions