change body style in angularjs

How to change body style in AngularJs?

Hello everyone, I am going to share the code sample for how to change body style in angularjs and all detail code as given below.


AngularJs code sample:

var app = angular.module('styleApp', []);
app.controller('styleAppCtrl', function ($scope, $http, $document) {
    angular.element($document).find('body').removeClass('my-style-calss');
});

HTML  code sample:

<div ng-app="styleApp" class="my-style-calss">
    <div ng-controller="styleCtrl">
        change body style in angularjs
    </div>
</div>

Full Live demo code(HTML + AngularJs):

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>change body style in angularjs</title>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script>
    <script>
        var app = angular.module('styleApp', []);
        app.controller('styleAppCtrl', function ($scope, $http, $document) {
            angular.element($document).find('body').removeClass('my-style-calss');
        });
    </script>
</head>
<body ng-app="styleApp" class="my-style-calss">
    <div ng-controller="styleCtrl">
        change body style in angularjs
    </div>
</body>
</html>

The output : go to link http://embed.plnkr.co/0AVI9E/preview



ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..

My Tech Blog - https://www.code-sample.com/
My Books - Book 1 and Book 2

www.code-sample.com/. Powered by Blogger.
^