{"id":23058708,"url":"https://github.com/suhdev/ngbasics","last_synced_at":"2025-07-17T00:06:47.314Z","repository":{"id":86646354,"uuid":"49827214","full_name":"suhdev/ngBasics","owner":"suhdev","description":"A set of utility services to use within AngularJS apps. Including a Model implementation for client-side MVC, a local model that can be attached to $scope and others. ","archived":false,"fork":false,"pushed_at":"2016-01-17T17:16:48.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T06:22:06.577Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/suhdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-17T17:16:19.000Z","updated_at":"2016-01-17T17:16:49.000Z","dependencies_parsed_at":"2023-03-06T03:45:37.637Z","dependency_job_id":null,"html_url":"https://github.com/suhdev/ngBasics","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/suhdev/ngBasics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suhdev%2FngBasics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suhdev%2FngBasics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suhdev%2FngBasics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suhdev%2FngBasics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/suhdev","download_url":"https://codeload.github.com/suhdev/ngBasics/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suhdev%2FngBasics/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265553330,"owners_count":23787054,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-16T02:17:15.203Z","updated_at":"2025-07-17T00:06:47.294Z","avatar_url":"https://github.com/suhdev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"#ngBasics\n\nA set of utility services to use within AngularJS apps. The following services are currently supporeted:\n\n1. Class\nThis services provides a basic prototypal-inhertance interface that can be extended by other classes to achieve OO in JavaScript. \n\n```javascript\nangular.module('Test',['ngBasics'])\n\t.factory('TestService',['Class',function(Class){\n\t\tvar TestService = Class.extend({\n\t\t\t//constructor\n\t\t\tinitialize:function(){\n\n\t\t\t},\n\t\t\tmethod1:function(){\n\n\t\t\t},\n\t\t\tmethod2:function(){\n\n\t\t\t}\n\t\t});\n\t\treturn TestService \n\t}]);\n\nangular.module('Test')\n\t.factory('TestService2',['TestService',function(TestService){\n\t\tvar TestService2 = TestService.extend({\n\t\t\tinitialize:function(){\n\t\t\t\t//call parent constructor\n\t\t\t\tTestService.prototype.initialize.call(this,arguments);\n\t\t\t},\n\t\t\tmethod1:function(){\n\t\t\t\tTestService.prototype.method1.call(this); \n\n\t\t\t\t//own implementation \n\t\t\t},\n\t\t\tmethod3:function(){\n\n\t\t\t}\n\t\t}); \n\n\t\treturn new TestService3();\n\t}]);\n\n\n```\n\n2. Events \nThis service provides implementation similar to that of the EventEmitter in NodeJS. The Events service extends the Class service and thus it keeps the same OO interface. \n\n```javascript\nangular.module('Test')\n\t.factory('BasicEmitter',['Events',function(Events){\n\t\tvar BasicEmitter = Events.extend({\n\t\t\tmethodx:function(){\n\n\t\t\t},\n\t\t\tmethody:function(){\n\n\t\t\t}\n\t\t}); \n\n\t\t//BasicEmitter now has the following methods\n\t\t// function on(eventName,callback,ctx) --\u003e alias \n\t\t// function addEventListener(eventName,callback,ctx)\n\t\t// function off(eventName,callback) --\u003e alias\n\t\t// function removeEventListener(eventName,callback) \n\t\t// to trigger an event \n\t\t// function fire(eventName,eventData)\n\t\treturn new BasicEmitter(); \n\t}]);\n\n```\n\n3. Util \nThis service provides a set of utility functions used by both the Class and Events services. \n\n4. IdGenerator \nThis service is used to generate unique identifiers \n\n5. Model \nThis service implements a Model interface for the (MVC) framework. The model class implements all restful methods. The class can also be extended to provide own implementation for the restful calls. Internally, the service use $http to perform Ajax calls and so it can be tested using the ngMock module. \n\n6. LocalModel\nThis is a client-side implementation of a model. The LocalModel service extends Events service. This is usually attached to the $scope of a controller, such that it can then be saved by calling ```save()``` method of the LocalModel. \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuhdev%2Fngbasics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuhdev%2Fngbasics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuhdev%2Fngbasics/lists"}