Source: directives/briefing/consulta/template-pdf/template-pdf.js

/**
 * @ngdoc directives
 * @name templatePdf
 * @module s4c.directives.briefing.consulta.templatePdf
 * 
 * @description `ConsultaBriefingCtrl` Controller da funcão de template

 *
 */
(function () {
    'use strict';

    angular.module('s4c.components.briefingOperacional')
        .directive('templatePdf', TemplatePDF);

    TemplatePDF.$inject = [
        '$compile',
        'TemplatePdf'
    ];

    /**
     * @method templatePdf
     * @param {*} $compile 
     * @param {*} TemplatePdf 
     */
    function TemplatePDF($compile, TemplatePdf) {
        return {
            restrict: 'E',
            templateUrl: 'app/directives/briefing/consulta/template-pdf/template-pdf.html',
            replace: true,
            scope: {
                briefing: '=briefing'
            },
            link: function ($scope, $elem) {


                $scope.$watch('briefing', function (newVal) {
                    if (newVal === undefined || newVal === null) {
                        return false;
                    }
                    $compile($elem.contents())($scope);
                    setTimeout(function () {
                        TemplatePdf._trigger('updatedHtml');
                    }, 0);
                });
            }
        }
    }
})();