-
-
Save ashishdasnurkar/c5b05dd80027295debc0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html ng-app="directivesModule"> | |
<head> | |
<meta name="description" content="Simple angular directive example"> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body > | |
<div highlight-me>Click Me!</div> | |
<script id="jsbin-javascript"> | |
// Code goes here | |
(function() { | |
var highlightMe = function () { | |
return { | |
restrict: 'A', | |
link: function(scope, elem, attrs) { | |
elem.on('mouseenter', function() { | |
elem.css('background-color', 'yellow'); | |
}); | |
elem.on('mouseleave', function() { | |
elem.css('background-color', 'white'); | |
}); | |
} | |
}; | |
}; | |
angular.module('directivesModule', []) | |
.directive('highlightMe', highlightMe); | |
}()); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">// Code goes here | |
(function() { | |
var highlightMe = function () { | |
return { | |
restrict: 'A', | |
link: function(scope, elem, attrs) { | |
elem.on('mouseenter', function() { | |
elem.css('background-color', 'yellow'); | |
}); | |
elem.on('mouseleave', function() { | |
elem.css('background-color', 'white'); | |
}); | |
} | |
}; | |
}; | |
angular.module('directivesModule', []) | |
.directive('highlightMe', highlightMe); | |
}());</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code goes here | |
(function() { | |
var highlightMe = function () { | |
return { | |
restrict: 'A', | |
link: function(scope, elem, attrs) { | |
elem.on('mouseenter', function() { | |
elem.css('background-color', 'yellow'); | |
}); | |
elem.on('mouseleave', function() { | |
elem.css('background-color', 'white'); | |
}); | |
} | |
}; | |
}; | |
angular.module('directivesModule', []) | |
.directive('highlightMe', highlightMe); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment