$addthis
addthis
A service for handling AddThis actions once your app is running.
Adds the addthis_widget.js
script onto the page if not
already present. Note: addthis_widget.js
will automatically be
added to your page unless turned off using
$addthisProvider.disableAutoAdd
.
app.controller('AcceptCookiesCtrl', ['$scope', '$addthis', function($scope, $addthis) {
$scope.userAccepts = function() {
$service.add();
};
}]);
Sets the addthis_config
variable on the page. If the pubid is set it
take it an use it elsewhere. Otherwise, it will add in the previously set
profile ID (if set) to addthis_config.pubid
. See
the addthis_config variable documentation for options.
Param | Type | Details |
---|---|---|
input | object | AddThis configuration object. See the addthis_config variable documentation for options. |
object | a copy of the |
app.controller('DoNotPrintOrEmailMeCtrl', ['$scope', '$addthis', function($scope, $addthis) {
var cfg = {
'services_exclude': 'print,mailto',
'ui_language': 'pl',
'data_track_clickback': false,
'ui_508_compliant': true
};
$addthis.config(cfg);
}]);
Applys new values from addthis_config
and addthis_share
,
updates the share url and title where not explicitly set and
reloads AddThis floating tools.
This module will catch most of the situations where AddThis' SmartLayers API needs to be refreshed. However, there may be some times siutations where the devleoper must call this directly, such as:
app.controller('AccountPageCtrl', ['$scope', '$addthis', '$window', function($scope, $addthis, $window) {
$window.document.title = 'Account Page';
$addthis.layersRefresh();
}]);
Returns a promise that resolves once AddThis' addthis_widget.js
loaded and is ready to use.
promise | A promise that resolves once |
app.controller('LoadMoreCatsCtrl', ['$scope', '$addthis', function($scope, $addthis) {
$addthis.loaded().then(function() {
// addthis_widget.js has loaded
});
}]);
Takes a twitter handle/username and uses it for twitter via. See https://www.addthis.com/academy/changes-to-how-twitter-works-with-addthis/ for more information
Param | Type | Details |
---|---|---|
the | stringfalse | twitter handle in a string or false to remove twitter handle from config |
app.controller('DoMagicCtrl', ['$scope', '$addthis', function($scope, $addthis) {
$addthis.twitterVia('addthis');
}]);
Takes a URL shortening name and a social service name, then enables URL shortening on that social service using the url shortening service. https://www.addthis.com/academy/url-shortening/ for more information
Param | Type | Details |
---|---|---|
urlShorteningService | string | The URL shortening service to enable |
socialService | string | The social service to enable the URL shortening on |
app.controller('DoMagicCtrl', ['$scope', '$addthis', function($scope, $addthis) {
$addthis.urlShortening('bitly', 'twitter');
}]);