# all files / Core/Components/Submit/ SubmitDirective.js

100% Statements 8/8
100% Branches 2/2
100% Functions 2/2
100% Lines 8/8

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33

    1

    1

    1
    2

    1
    2
    1

    1
     'use strict';

    // Utilities:
    var _ = require('lodash');
    var fs = require('fs');

    // Module:
    var Core = require('../../Core');

    var SubmitDirective = function () {
        return {
            restrict: 'E',

            scope: {
                action: '@'
            },

            /* eslint-disable no-path-concat */
            template: fs.readFileSync(__dirname + '/Submit.html', 'utf8'),
            /* eslint-enable no-path-concat */

            link: link
        };

        function link ($scope) {
            if (_.isUndefined($scope.action)) {
                throw new Error('The "tractor-submit" directive requires an "action" attribute.');
            }
        }
    };

    Core.directive('tractorSubmit', SubmitDirective);