UNPKG

@stratusjs/angularjs

Version:

This is the AngularJS package for StratusJS.

113 lines (111 loc) 4.86 kB
System.register(["@stratusjs/runtime/stratus", "lodash", "angular-material", "../services/model", "../services/collection", "../services/registry", "@stratusjs/core/misc", "@stratusjs/core/environment"], function (exports_1, context_1) { "use strict"; var stratus_1, lodash_1, model_1, collection_1, registry_1, misc_1, environment_1, min, name, localPath; var __moduleName = context_1 && context_1.id; return { setters: [ function (stratus_1_1) { stratus_1 = stratus_1_1; }, function (lodash_1_1) { lodash_1 = lodash_1_1; }, function (_1) { }, function (model_1_1) { model_1 = model_1_1; }, function (collection_1_1) { collection_1 = collection_1_1; }, function (registry_1_1) { registry_1 = registry_1_1; }, function (misc_1_1) { misc_1 = misc_1_1; }, function (environment_1_1) { environment_1 = environment_1_1; } ], execute: function () { min = !environment_1.cookie('env') ? '.min' : ''; name = 'base'; localPath = '@stratusjs/angularjs/src/components'; stratus_1.Stratus.Components.Base = { transclude: { model: '?stratusBaseModel' }, bindings: { elementId: '@', ngModel: '=', property: '@', target: '@', id: '@', manifest: '@', decouple: '@', direct: '@', api: '@', urlRoot: '@', limit: '@', options: '<' }, controller($scope, $attrs) { $scope.uid = misc_1.safeUniqueId(name); stratus_1.Stratus.Instances[$scope.uid] = $scope; $scope.elementId = $attrs.elementId || $scope.uid; stratus_1.Stratus.Internals.CssLoader(`${stratus_1.Stratus.BaseUrl + stratus_1.Stratus.BundlePath + localPath}/${name}${min}.css`).then(); $scope.initialized = false; $scope.property = $attrs.property || null; $scope.data = null; $scope.model = null; $scope.collection = null; if ($attrs.target) { $scope.registry = $scope.registry || new registry_1.Registry(); $scope.registry.fetch($attrs, $scope).then(); } $scope.$watch('$ctrl.ngModel', (data) => { if (data instanceof model_1.Model && data !== $scope.model) { $scope.model = data; } else if (data instanceof collection_1.Collection && data !== $scope.collection) { $scope.collection = data; } }); $scope.initialize = () => { if ($scope.initialized) { return; } if ($scope.model) { $scope.initialized = true; $scope.model.on('change', () => { console.log('model changed:', $scope.model.patch); }); } if ($scope.collection) { $scope.initialized = true; console.log('collection available'); } }; $scope.$watch('$scope.model.completed', (newVal, oldVal) => { if (!newVal || lodash_1.isEqual(newVal, oldVal)) { return; } $scope.initialize(); }); $scope.$watch('$scope.collection.completed', (newVal, oldVal) => { if (!newVal || lodash_1.isEqual(newVal, oldVal)) { return; } $scope.initialize(); }); if (environment_1.cookie('env')) { console.log(name, 'component:', $scope, $attrs); } }, templateUrl: `${stratus_1.Stratus.BaseUrl}${stratus_1.Stratus.DeploymentPath}${localPath}/${name}${min}.html` }; } }; }); //# sourceMappingURL=base.js.map