Skip to content

Instantly share code, notes, and snippets.

@VanDalkvist
Last active August 29, 2015 14:03
Show Gist options
  • Save VanDalkvist/05caa9d93bd775c51d13 to your computer and use it in GitHub Desktop.
Save VanDalkvist/05caa9d93bd775c51d13 to your computer and use it in GitHub Desktop.
Директива для подсветки кода (source - http://habrahabr.ru/post/164493/)
.directive('uiSource', function () {
return {
restrict: 'EA',
compile: function (elem) {
var escape = function(content) {
return content
.replace(/\&/g, '&')
.replace(/\</g, '<')
.replace(/\>/g, '>')
.replace(/"/g, '"');
};
var pre = angular.element('<pre class="prettyprint linenums"></pre>');
pre.append(prettyPrintOne(escape(elem.html().slice(1)), undefined, true));
elem.replaceWith(pre);
}
};
});
<ui-source>
<ui-source>
<div>
<label>Name:</label>
<input type="text" ng-model="yourName" placeholder="Enter a name here">
<hr>
<h1>Hello {{yourName}}!</h1>
</div>
</ui-source>
</ui-source>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment