Coder Social home page Coder Social logo

cornflourblue / angulike Goto Github PK

View Code? Open in Web Editor NEW
58.0 4.0 41.0 12 KB

AngularJS directives for social sharing buttons - Facebook Like, Google+, Twitter and Pinterest

Home Page: http://jasonwatmore.com/post/2014/08/01/AngularJS-directives-for-social-sharing-buttons-Facebook-Like-GooglePlus-Twitter-and-Pinterest.aspx

License: MIT License

JavaScript 100.00%

angulike's Introduction

angulike

AngularJS directives for social sharing buttons - Facebook Like, Google+, Twitter and Pinterest

Demo

To see a demo and further details go to http://jasonwatmore.com/post/2014/08/01/AngularJS-directives-for-social-sharing-buttons-Facebook-Like-GooglePlus-Twitter-and-Pinterest.aspx

Installation

Install using bower: bower install angulike

Alternatively download the code and include the angulike.js file in your page.

Add the 'angulike' directive as a dependency of your AngularJS application:

angular.module('myApp', ['angulike']);

Usage

Facebook Like

Create an empty div with the fb-like attribute.

<div fb-like></div>

To use a custom URL for the facebook like button:

<div fb-like="myModel.Url"></div>

Google+

Create an empty div with the google-plus attribute.

<div google-plus></div>

To use a custom URL for the google plus button:

<div google-plus="myModel.Url"></div>

Twitter

Create an empty div with the tweet attribute, the value of the attribute contains the name of the model object for the tweet text.

<div tweet="myModel.Name"></div>

To use a custom URL for the tweet button:

<div tweet="myModel.Name" tweet-url="myModel.Url"></div>

Pinterest

Create an empty div with the pin-it and pin-it-image attributes, the pin-it attribute contains the name of the model object for the description and the pin-it-image attribute contains the name of the model object for the image url:

<div pin-it="myModel.Name" pin-it-image="myModel.ImageUrl"></div>

To use a custom URL for the pinterest button:

<div pin-it="myModel.Name" pin-it-image="myModel.ImageUrl" pin-it-url="myModel.Url"></div>

angulike's People

Contributors

cornflourblue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

angulike's Issues

Get rid of the jquery dependency

A lot of people recommend not to mix jquery with angularjs, would it be possible to replace $.getScript with $http.get(src) and eval(response) to make it execute the script? (any thoughts from a more experienced angular dev welcome)

How to use in Ionic application

I wan to use this Module in my ionic application, but it is not working violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' 'unsafe-eval'" Says But working fine in Angular Web app.

Custom buttons?

For example on Facebook is there a way to create a customised button?

10 $digest() iterations reached. Aborting!

I am using angulike like this -

          span(pin-it="product.title" pin-it-image="product.photos[0].image_url")
          span(tweet="product.title")
          span(fb-like="")
          span(google-plus="")

product.title & product.photos[0].image_url are dynamic object properties loaded from an AJAX call.

On first page load ('/product/1'), everything is fine. product 1's model is loaded and the watchers for the above social plugins fires.

Next, I click a click to go to the next page '/product/2' which uses the same template above. My code then fetches product 2's model. Then I get these errors:

Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [["pinIt; newVal: \"\"; oldVal: undefined","tweet; newVal: \"\"; oldVal: undefined"],["pinIt; newVal: \"\"; oldVal: undefined","tweet; newVal: \"\"; oldVal: undefined"],["pinIt; newVal: \"\"; oldVal: undefined","tweet; newVal: \"\"; oldVal: undefined"],["pinIt; newVal: \"\"; oldVal: undefined","tweet; newVal: \"\"; oldVal: undefined"],["pinIt; newVal: \"\"; oldVal: undefined","tweet; newVal: \"\"; oldVal: undefined"]]
http://errors.angularjs.org/1.3.1/$rootScope/infdig?p0=10&p1=%5B%5B%22pinIt…%22tweet%3B%20newVal%3A%20%5C%22%5C%22%3B%20oldVal%3A%20undefined%22%5D%5D
    at http://127.0.0.1:3000/bower_components/angular/angular.js:80:12
    at Scope.$digest (http://127.0.0.1:3000/bower_components/angular/angular.js:13990:19)
    at Scope.$apply (http://127.0.0.1:3000/bower_components/angular/angular.js:14214:24)
    at http://127.0.0.1:3000/bower_components/angular/angular.js:15945:36
    at completeOutstandingRequest (http://127.0.0.1:3000/bower_components/angular/angular.js:4842:10)
    at http://127.0.0.1:3000/bower_components/angular/angular.js:5215:7 angular.js:11339
Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [["pinIt; newVal: \"\"; oldVal: undefined","tweet; newVal: \"\"; oldVal: undefined"],["pinIt; newVal: \"\"; oldVal: undefined","tweet; newVal: \"\"; oldVal: undefined"],["pinIt; newVal: \"\"; oldVal: undefined","tweet; newVal: \"\"; oldVal: undefined"],["pinIt; newVal: \"\"; oldVal: undefined","tweet; newVal: \"\"; oldVal: undefined"],["pinIt; newVal: \"\"; oldVal: undefined","tweet; newVal: \"\"; oldVal: undefined"]]
http://errors.angularjs.org/1.3.1/$rootScope/infdig?p0=10&p1=%5B%5B%22pinIt…%22tweet%3B%20newVal%3A%20%5C%22%5C%22%3B%20oldVal%3A%20undefined%22%5D%5D angular.js:80
Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [["pinIt; newVal: \"\"; oldVal: undefined","tweet; newVal: \"\"; oldVal: undefined"],["pinIt; newVal: \"\"; oldVal: undefined","tweet; newVal: \"\"; oldVal: undefined"],["pinIt; newVal: \"\"; oldVal: undefined","tweet; newVal: \"\"; oldVal: undefined"],["pinIt; newVal: \"\"; oldVal: undefined","tweet; newVal: \"\"; oldVal: undefined"],["pinIt; newVal: \"\"; oldVal: undefined","tweet; newVal: \"\"; oldVal: undefined"]]
http://errors.angularjs.org/1.3.1/$rootScope/infdig?p0=10&p1=%5B%5B%22pinIt…%22tweet%3B%20newVal%3A%20%5C%22%5C%22%3B%20oldVal%3A%20undefined%22%5D%5D
    at http://127.0.0.1:3000/bower_components/angular/angular.js:80:12
    at Scope.$digest (http://127.0.0.1:3000/bower_components/angular/angular.js:13990:19)
    at Scope.$apply (http://127.0.0.1:3000/bower_components/angular/angular.js:14214:24)
    at done (http://127.0.0.1:3000/bower_components/angular/angular.js:9474:47)
    at completeRequest (http://127.0.0.1:3000/bower_components/angular/angular.js:9659:7)
    at XMLHttpRequest.requestLoaded (http://127.0.0.1:3000/bower_components/angular/angular.js:9602:9) angular.js:11339
Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [["pinIt; newVal: \"\"; oldVal: undefined","tweet; newVal: \"\"; oldVal: undefined"],["pinIt; newVal: \"\"; oldVal: undefined","tweet; newVal: \"\"; oldVal: undefined"],["pinIt; newVal: \"\"; oldVal: undefined","tweet; newVal: \"\"; oldVal: undefined"],["pinIt; newVal: \"\"; oldVal: undefined","tweet; newVal: \"\"; oldVal: undefined"],["pinIt; newVal: \"\"; oldVal: undefined","tweet; newVal: \"\"; oldVal: undefined"]]

Can't get Tweet to work

FB directive works fine, but after following you instructions and copying

<div tweet="myModel.Name"></div>

into my code, I couldn't get a tweet link to appear.

Set language from $rootScope

Hi,

Thanks for a great module! I think it would be a great idea to implement another variable on the $rootScope to specify a language for the fbLike-directive. As it is now you always get english.

npm package distrib evolution

Could you create a npm package of this component in order to use it with npm / browserify ?
It will complement the bower packaging.

How could replace the share button of angulike by a custom ( facebook ) ?

I would like to replace the share button of angulike by this custom , what is the correct way to do the replacement ?

<div id="fb-root"></div>
<a href="http://www.google.com/" data-image="Article img url" data-title="Article Title" data-desc="Some description for this article" class="fb_share">
    <img src="http://www.synermous.com/data/images/fb-icon.svg" alt="" width="50" height="50">
</a>
window.fbAsyncInit = function() {
    FB.init({
        appId: <your facebook app id>,
        status: true,
        cookie: true,
        xfbml: true
    });
};

(function(d, debug){var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];if   (d.getElementById(id)) {return;}js = d.createElement('script'); js.id = id; js.async = true;js.src = "//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";ref.parentNode.insertBefore(js, ref);}(document, /*debug*/ false));

function postToFeed(title, desc, url, image) {
    var obj = {method: 'feed',link: url, picture: image,name: title,description: desc};
    function callback(response) {}
    FB.ui(obj, callback);
}

var fbShareBtn = document.querySelector('.fb_share');
fbShareBtn.addEventListener('click', function(e) {
    e.preventDefault();
    var title = fbShareBtn.getAttribute('data-title'),
        desc = fbShareBtn.getAttribute('data-desc'),
        url = fbShareBtn.getAttribute('href'),
        image = fbShareBtn.getAttribute('data-image');
    postToFeed(title, desc, url, image);

    return false;
});

http://tedshd.logdown.com/posts/200979-javascript-custom-facebook-share-button

Updating buttons on state change

Hello, I don't quite understand why you stop the $watch on scope.fbLike. It seems to me like this prevents the button from updating, when the view changes. I haven't looked into the other buttons yet, only FB, but I think keeping a $watch on the url is essential

Facebook and Google+ Icons are not working with URLs containing query params.

bower install with latest angular fails due to version mismatch.

Unable to find a suitable version for angular, please choose one:
1) angular#~1.2.16 which resolved to 1.2.28 and is required by angulike#de2ec79068
2) angular#~1.3.10 which resolved to 1.3.10 and is required by songrhyme
3) angular#1.3.10 which resolved to 1.3.10 and is required by angular-route#1.3.10
4) angular#~1 which resolved to 1.3.11 and is required by ngDialog#0.3.9

Is this working with android and ios hybrid app?

Hi

Thanks for better directive , I created a apk for android and install on device, but below message shows.

my question is : does this work for app?

if (window.location.href.indexOf('http') != 0) {
alert("This demo must be run on a web server (i.e. the url must start with http/https), it won't work by opening the file directly in a browser.");
}

Thanks
Brijmohan

twitter mention @somebody

Hello, is it possible to add twitter mentions through this library?

something like:

tweet-mention="somebody"

Also considering hashtags too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.