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

26 lines (25 loc) 933 B
app.directive('zlQueryBuilder', function(zapiPath) { return { restrict: 'E', scope: { field: '=', model: '=', key: '@', zlClass: '@?' }, replace: false, template: '<div ng-include src="contentUrl" include-replace></div>', controller: function($scope) { if (typeof $scope.zlClass === 'undefined') $scope.zlClass = "form-control input-lg"; $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/queryBuilder/" + type + ".html"; } } }; });