app.directive('zlDynamicField', function () {
    return {
        restrict: 'E',
        scope: {
            field: '='
        },
        replace: false,
        template: '<div ng-include src="contentUrl" include-replace></div>',
        link: function (scope, element, attrs) {
            var type = scope.field.type || 'Unknown';
            if (scope.field.type === 'ObjectId' && typeof scope.field.ref === 'undefined') {
                type = "String";
            }
            scope.contentUrl = "directives/dynamicField/" + type + ".html";
        }
    };
});
