Blame view

directives/BindHtmlCompile.directive.js 628 Bytes
6e6aa9b0   Tarpit Grover   Basic Setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
(function (angular) {
    'use strict';

    var module = angular.module('framework.directives.utils', []);

    module.directive('bindHtmlCompile', ['$compile', bindHtmlCompile]);

    function bindHtmlCompile($compile) {
        return {
            restrict: 'A',
            link: function (scope, element, attrs) {
                scope.$watch(function () {
                    return scope.$eval(attrs.bindHtmlCompile);
                }, function (value) {
                    element.html(value);
                    $compile(element.contents())(scope);
                });
            }
        };
    }
}(angular));