'use strict';

/**
 * @ngdoc directive
 * @name annotationAppApp.directive:compile
 * @description
 * # compile
 */
angular.module('app')
    .directive('compile', function($compile) {
        return {
            scope: {
                compile: '='
            },
            restrict: 'A',
            link: function postLink(scope, element) {

                scope.$watch(function() {
                    return scope.compile;
                }, function(newV) {
                    if (newV) {
                        element.html(newV);
                        $compile(element.contents())(scope);
                    }
                });
            }
        };
    });