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 Blogs - https://code-sample.com and https://code-sample.xyz
My Book1 - BEST SELLING ANGULAR BOOK (INCLUDING ALL VERSIONS 2, 4, 5, 6, 7)
My Book2 - ANGULAR 2 INTERVIEW QUESTIONS BOOK - Both Books are Available on WorldWide.

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