Created
November 16, 2012 01:59
-
-
Save tjstebbing/4083252 to your computer and use it in GitHub Desktop.
live styles
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> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js"></script> | |
<script> | |
function CSS($scope) { | |
$scope.css = "body {\n background-color: #000;\n}"; | |
} | |
angular.module('stylatron', []).directive('ngStyleContents', | |
function() { | |
return function(scope, element, attr) { | |
scope.$watch(attr.ngStyleContents, function(newContents, oldContents) { | |
if (newContents != oldContents) { | |
element.nodeValue = newContents; | |
} | |
}); | |
} | |
}); | |
</script> | |
</head> | |
<body ng-app='stylatron' ng-controller="CSS"> | |
<style ng-style-contents='css'></style> | |
<textarea ng-model="css" cols='80' rows='20'> </textarea> | |
<h2>hmmmm</h2> | |
<div class='test'>{{css}}</div> | |
</body> | |
</html> |
raffecat
commented
Nov 16, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment