{"id":20324916,"url":"https://github.com/xeeo/ng-addthis","last_synced_at":"2025-06-26T12:05:28.409Z","repository":{"id":35238760,"uuid":"39498217","full_name":"xeeo/ng-addthis","owner":"xeeo","description":"AddThis Integration with Angular — Edit","archived":false,"fork":false,"pushed_at":"2015-07-27T13:53:53.000Z","size":124,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T15:04:19.533Z","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/xeeo.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":"2015-07-22T09:44:03.000Z","updated_at":"2017-01-11T10:48:47.000Z","dependencies_parsed_at":"2022-09-16T15:23:29.200Z","dependency_job_id":null,"html_url":"https://github.com/xeeo/ng-addthis","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xeeo%2Fng-addthis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xeeo%2Fng-addthis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xeeo%2Fng-addthis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xeeo%2Fng-addthis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xeeo","download_url":"https://codeload.github.com/xeeo/ng-addthis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241828221,"owners_count":20026867,"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-11-14T19:38:08.254Z","updated_at":"2025-03-04T10:24:11.713Z","avatar_url":"https://github.com/xeeo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Angular AddThis Module\n\nA simple wrapper to pull in the AddThis snippet with an AngularJS-based application. This structure is based on [ng-optimizely](https://github.com/jacopotarantino/ng-optimizely)\n\nThis module provides only a simple API to download the AddThis snippet onto the page. The `loadProject` method(usage described below) returns a promise so you can delay execution until after the snippet has loaded.\n\n## Install\n\n```bash\n$ bower install --save ng-addthis\n```\n\nThen require ng-addthis in your application:\n\n```javascript\nvar app = angular.module('app', ['ng-addthis']);\n```\n\n## Run\n\nIn your app's run block execute the `initAddThis` method:\n\n```javascript\nangular.module('app')\n    .run(['addThisService', function(addThisService) {\n        addThisService.initAddThis('12345678');\n    }]);\n```\n\nAnother way to load the library and avoid a FOUC is to use a router like [ui-router](https://github.com/angular-ui/ui-router) that allows you to defer pageload until after all of a given route's dependencies have been loaded. The `loadProject` method returns a promise so you can use it with any give plugin or framework but ui-router is a really good choice for most projects.\n\n```javascript\napp.config(function($stateProvider, addThisService) {\n  $stateProvider.state('app.dashboard', {\n    // ... other stuff ...\n    resolve: {\n      addThisService: function(addThisService) {\n        addThisService.loadProject('12345678');\n      }\n    }\n  });\n});\n```\n\nAn important aspect is that you might not want to have the AddThis widget on all pages. So that there is a function you can use to hide the script. This can be used on state change for example.\n\n```javascript\nangular.module('app')\n    .run(['$rootScope', 'addThisService', function($rootScope, addThisService) {\n        $rootScope.$on('$stateChangeStart', \n            function(event, toState, toParams, fromState, fromParams) {\n                if (toState.name === 'your--state') {\n                    addThisService.loadProject('12345678');\n                } else {\n                    addThisService.hideLayers(0);\n                }\n            });\n    }]);\n```\n\n## Test\n\nI can say TODO ... but I won't do them .... This thing is already in production so enjoy :D\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2014 Geana Raul\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxeeo%2Fng-addthis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxeeo%2Fng-addthis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxeeo%2Fng-addthis/lists"}