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

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - http://www.code-sample.com and http://www.code-sample.xyz
My Books - Google Amazon and Flipkart Book Store!

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.
ASK Questions
SQL Server NodeJs TypeScript JavaScript Angular SQL Server My Book