Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html  lang="en" >
    <head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.1/angular.min.js"></script>
        <meta charset="UTF-8">
        <title>
            AngularJS $rootElement Example
        </title>
    </head>
    <body ng-app="myApp">
        <my-directive></my-directive>
    </body>
</html>
 
var myApp= angular.module("myApp",[]);
myApp.directive("myDirective",
    ['$rootElement',"$log",
    function($rootElement,$log){
    return {
        restrict:"E",
        template:"<button ng-click='changeGreenBackground()'>Change BackGround {{color}}</button>",
        link: function(scope,element,attr){
          scope.changeGreenBackground= function(){
            $log.log($rootElement);
            $rootElement.css("background","#00ff00");
          };
        }
    };
}]);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x