Using Rainbow with Angular
After following the instructions for setting up Rainbow, include this directive:
/**
* Directive for using rainbow syntax highlighter with angular
*/
angular.module('MyApp')
.directive('rainbowBlock', function () {
return {
restrict: 'A',
link: function() {
Rainbow.color();
}
};
});
Then add rainbow-block
as an attribute on the pre
element in the html:
<pre rainbow-block><code data-language="javascript">//my code here</code></pre>
...and it will totally work. Hooray.
hi, i have a problem. i want to place some variable value inside the code. If i use your code, the variable is not properly placed. output looks like
Here i expect to have value of the name variable.
How to fix it? Can we call
Rainbow.color()
after everything is placed.