lib/ngapp/generic.directives.js
function addDirective(directiveName, dashCase, attrName, filterType, isBind, isBindOnce, isFilter) {
        app.directive(directiveName, ['i18n', 'config', function (i18n, config) {

            function setValue(scope, element, attrs, value) {
                value = !isFilter ? value :
                    filterType === 'file' ?
                        (config.staticFileRoot + value) :
                        i18n.translate(value, scope);

                attrName === 'text' ?
                    element.text(value) :
                    attrName === 'class' ?
                        attrs.$addClass(value) :
                        attrs.$set(attrName, value, scope);
            }

            return {
                priority: 101,
                link: function linkFn(scope, element, attrs) {
                    var originalValue = attrs[directiveName];

                    // if we are binding to the attribute value
                    if (isBind) {
                        var unwatch = scope.$watch(originalValue, function (value) {
                            if (value !== undefined && value !== null) {
                                setValue(scope, element, attrs, value);
                                if (isBindOnce && unwatch) { unwatch(); }
                            }
                        });
                    }

                    // else we are not binding, but we want to do some filtering
                    else if (!isBind && isFilter && filterType !== null) {
                        var fTextVal = (element && element.length && element[0].attributes &&
                            element[0].attributes[dashCase] && element[0].attributes[dashCase].value) || '';

                        // if the value contains {{ it means there is interpolation
                        if (fTextVal.indexOf('{{') >= 0) {
                            var unobserve = attrs.$observe(directiveName, function (value) {
                                setValue(scope, element, attrs, value);
                                if (isBindOnce && unobserve) { unobserve(); }
                            });
                        }
                        // else we are very simply setting the value
                        else {
                            setValue(scope, element, attrs, originalValue);
                        }
                    }
                    else {
                        throw new Error('Not bind nor filter in generic addDirective for ' + originalValue);
                    }
                }
            };
        }]);
    }
function addDirective(directiveName, dashCase, attrName, filterType, isBind, isBindOnce, isFilter) {
        app.directive(directiveName, ['i18n', 'config', function (i18n, config) {

            function setValue(scope, element, attrs, value) {
                value = !isFilter ? value :
                    filterType === 'file' ?
                        (config.staticFileRoot + value) :
                        i18n.translate(value, scope);

                attrName === 'text' ?
                    element.text(value) :
                    attrName === 'class' ?
                        attrs.$addClass(value) :
                        attrs.$set(attrName, value, scope);
            }

            return {
                priority: 101,
                link: function linkFn(scope, element, attrs) {
                    var originalValue = attrs[directiveName];

                    // if we are binding to the attribute value
                    if (isBind) {
                        var unwatch = scope.$watch(originalValue, function (value) {
                            if (value !== undefined && value !== null) {
                                setValue(scope, element, attrs, value);
                                if (isBindOnce && unwatch) { unwatch(); }
                            }
                        });
                    }

                    // else we are not binding, but we want to do some filtering
                    else if (!isBind && isFilter && filterType !== null) {
                        var fTextVal = (element && element.length && element[0].attributes &&
                            element[0].attributes[dashCase] && element[0].attributes[dashCase].value) || '';

                        // if the value contains {{ it means there is interpolation
                        if (fTextVal.indexOf('{{') >= 0) {
                            var unobserve = attrs.$observe(directiveName, function (value) {
                                setValue(scope, element, attrs, value);
                                if (isBindOnce && unobserve) { unobserve(); }
                            });
                        }
                        // else we are very simply setting the value
                        else {
                            setValue(scope, element, attrs, originalValue);
                        }
                    }
                    else {
                        throw new Error('Not bind nor filter in generic addDirective for ' + originalValue);
                    }
                }
            };
        }]);
    }
function addDirective ( directiveName , dashCase , attrName , filterType , isBind , isBindOnce , isFilter ) { app . directive ( directiveName , [ 'i18n' , 'config' , function ( i18n , config ) { function setValue ( scope , element , attrs , value ) { value = ! isFilter ? value : filterType === 'file' ? ( config . staticFileRoot + value ) : i18n . translate ( value , scope ) ; attrName === 'text' ? element . text ( value ) : attrName === 'class' ? attrs . $addClass ( value ) : attrs . $set ( attrName , value , scope ) ; } return { priority : 101 , link : function linkFn ( scope , element , attrs ) { var originalValue = attrs [ directiveName ] ; // if we are binding to the attribute value if ( isBind ) { var unwatch = scope . $watch ( originalValue , function ( value ) { if ( value !== undefined && value !== null ) { setValue ( scope , element , attrs , value ) ; if ( isBindOnce && unwatch ) { unwatch ( ) ; } } } ) ; } // else we are not binding, but we want to do some filtering else if ( ! isBind && isFilter && filterType !== null ) { var fTextVal = ( element && element . length && element [ 0 ] . attributes && element [ 0 ] . attributes [ dashCase ] && element [ 0 ] . attributes [ dashCase ] . value ) || '' ; // if the value contains {{ it means there is interpolation if ( fTextVal . indexOf ( '{{' ) >= 0 ) { var unobserve = attrs . $observe ( directiveName , function ( value ) { setValue ( scope , element , attrs , value ) ; if ( isBindOnce && unobserve ) { unobserve ( ) ; } } ) ; } // else we are very simply setting the value else { setValue ( scope , element , attrs , originalValue ) ; } } else { throw new Error ( 'Not bind nor filter in generic addDirective for ' + originalValue ) ; } } } ; } ] ) ; }
function used for each of the generic directives
function used for each of the generic directives