Skip to content

Instantly share code, notes, and snippets.

@SelrahcD
Last active December 25, 2015 21:29
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save SelrahcD/7042692 to your computer and use it in GitHub Desktop.
Save SelrahcD/7042692 to your computer and use it in GitHub Desktop.
AngularJs directive for PrismJs
angular.module('Prism', []).
directive('prism', [function() {
return {
restrict: 'A',
link: function ($scope, element, attrs) {
element.ready(function() {
Prism.highlightElement(element[0]);
});
}
}
}]
);
@matt-mcdaniel
Copy link

Solved my problem using ui-router with Prism. Really useful for anyone looking to do the same.

@vinhlh
Copy link

vinhlh commented May 29, 2015

You need to add this lines inside link function to make Prism updates when there are a change in your model:

$scope.$watch('{youModelName}', function () {
    Prism.highlightElement(element[0]);
});

@sunsus
Copy link

sunsus commented Sep 16, 2015

Can you update to this Version:
https://gist.github.com/sunsus/2a5ce3fbe15f447e7fa7

It is better compatible with Plugins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment