pc035860 / angular-highlightjs

AngularJS directive for syntax highlighting with highlight.js
http://pc035860.github.io/angular-highlightjs/example/
MIT License
294 stars 53 forks source link

passing values for include from $scope variables not working #49

Closed balasivagnanam closed 8 years ago

balasivagnanam commented 8 years ago

Hi thanks for the awesome library, it is highly useful.

Currently I am facing an issue in rendering the code block.

In my case the code block that I want to render, is in separate file. Also I want to make this configurable, this will be an input from JSON file. But when I use a scope variable as a paramater inside "include" it is not working.

<div hljs include="'file.html'">
  </div>
  <h5>not working</h5>
  <div hljs include="'{{fileName}}'">
</div>

check the plunker that I created for this. http://plnkr.co/edit/4VoplzSggll1Qei6L2qO

pc035860 commented 8 years ago

Hi @balasivagnanam ,

The include directive in angular-highlightjs as well as the built-in ng-include accept angular expression.

Simply put fileName in the include and it'll wok, since fileName itself is a valid angular expression whose eval result is "file.html" (string).

<div hljs include="fileName"></div>

Here's the working plunk http://plnkr.co/edit/BRY4MHZHM5BqLWKU0ibV

balasivagnanam commented 8 years ago

that works. thanks a lot. I am new to angular, sorry about that stupid question.