demo/demo.js
function code($window) {
    return {
      restrict: 'E',
      require: '?ngModel',
      /**
       *
       * @param {$rootScope.Scope} scope Element Scope
       * @param {angular.element} element AngularJS element
       * @param {$compile.directive.Attributes} attrs AngularJS Attributes object
       * @param {NgModelController} ngModel ngModel controller object
       */
      link: function link(scope, element, attrs, ngModel) {
        var pre;
        if (!ngModel) {
          return;
        }

        pre = element.wrap('<pre></pre>');
        element.addClass(attrs.lang);

        ngModel.$render = function $render() {
          element.text(ngModel.$viewValue);
          $window.hljs.highlightBlock(pre[0]);
        };

      }
    };
  }
function code($window) {
    return {
      restrict: 'E',
      require: '?ngModel',
      /**
       *
       * @param {$rootScope.Scope} scope Element Scope
       * @param {angular.element} element AngularJS element
       * @param {$compile.directive.Attributes} attrs AngularJS Attributes object
       * @param {NgModelController} ngModel ngModel controller object
       */
      link: function link(scope, element, attrs, ngModel) {
        var pre;
        if (!ngModel) {
          return;
        }

        pre = element.wrap('<pre></pre>');
        element.addClass(attrs.lang);

        ngModel.$render = function $render() {
          element.text(ngModel.$viewValue);
          $window.hljs.highlightBlock(pre[0]);
        };

      }
    };
  }
function code ( $window ) { return { restrict : 'E' , require : '?ngModel' , /**
       *
       * @param {$rootScope.Scope} scope Element Scope
       * @param {angular.element} element AngularJS element
       * @param {$compile.directive.Attributes} attrs AngularJS Attributes object
       * @param {NgModelController} ngModel ngModel controller object
       */ link : function link ( scope , element , attrs , ngModel ) { var pre ; if ( ! ngModel ) { return ; } pre = element . wrap ( '<pre></pre>' ) ; element . addClass ( attrs . lang ) ; ngModel . $render = function $render ( ) { element . text ( ngModel . $viewValue ) ; $window . hljs . highlightBlock ( pre [ 0 ] ) ; } ; } } ; }
Renders source code with highlight.js
@example
$scope.foo = "var bar = 'baz';";
// <source ng-model="foo" lang="js"></source>
Renders source code with highlight . js