UNPKG

zettapi_client

Version:

Client side CRUD operations in angular to use with zettapi_server rest api to get started quickly in any CMS project

24 lines (22 loc) 790 B
app.directive('zlDynamicField', function (zapiPath) { return { restrict: 'E', scope: { field: '=', value: '=' }, replace: false, template: '<div ng-include src="contentUrl" include-replace></div>', controller: function ($scope) { $scope.$watch('field.type', onFieldChange); function onFieldChange(newField) { if (!newField) return; var type = $scope.field.type || 'Unknown'; if ($scope.field.type === 'ObjectId' && typeof $scope.field.ref === 'undefined') { type = "String"; } $scope.contentUrl = zapiPath + "/directives/dynamicField/" + type + ".html"; } } }; });