0

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

1 Answer 1

1

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

    `http://jsfiddle.net/56512rmc/2`
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.