(function () { 'use strict'; /** * @typedef {Object} AttributeViewData * @property {String} dataType "numeric"|"text"|"datetime" * @property {?String} uofmPre * @property {?String} uofmPost * * @property {?Number|String} numericValue * @property {?Number|String} decimalRound * * @property {?String} textValue * * @property {?Date|String} datetimeValue * @property {?String} datetimeOutputFormatJs * * @property {String} parsedValue */ var name = 'adAttributeView'; angular.module('app.directive') .directive('adAttributeView', ['$parse', '$filter', 'attribute', function ($parse, $filter, attribute) { return { templateUrl: 'directive/' + name + '/' + name + '.html', replace: true, scope: {}, link: function (scope, element, attr) { var expr = $parse(attr[name]); /** @type {AttributeViewData} */ var data = scope.data = expr(scope.$parent); scope.parseValue = function () { if ('parsedValue' in data) { return data.parsedValue; } data.parsedValue = attribute.toText(data); return data.parsedValue; }; } }; }]); })();