Giter Site home page Giter Site logo

Comments (10)

karljv avatar karljv commented on May 30, 2024 1

Since the developer doesnt know his own plugin, I decided to go poking around the source code. He forgot to tell me that for the likes to be counted, you have to include the

[sbShowCount]="true"

on the damn directive.

Hope this helps anyone else trying to get this to work!

The modules were fine, I ended up having the forRoot declaration in my app.module.ts and just the ShareButtonsModule imports and exports in my shared.module.ts

from ngx-sharebuttons.

MurhafSousli avatar MurhafSousli commented on May 30, 2024 1

@karljv I don't have to feed you with a spoon, this is explained in details in the docs and in the demo, but you don't read ITS HERE. and no one works for you here... you should be thankful that I'm replying you.

from ngx-sharebuttons.

karljv avatar karljv commented on May 30, 2024

Also I think, this project is vital and awesome, but as a programmer, I've no real need for premade buttons and such, but more need for functionality I can anchor on my own DOM items. And data I can pull for services, ala give in FACEBOOK and an URL, and get the like count (as described above).

from ngx-sharebuttons.

MurhafSousli avatar MurhafSousli commented on May 30, 2024

@karljv Yes you can,

<div style="display: none" [shareButton]="'facebook'" [sbUrl]="someUrl" (sbCount)="fbCount = $event"></div>
<div class="fb-count">{{fbCount | nFormatter}}</div>

You will also get a new count when you change the URL dynamically

from ngx-sharebuttons.

karljv avatar karljv commented on May 30, 2024

I put a variable
public fbCount
into my components.ts

and inside component.html I have

<div style="display: none;" [shareButton]="'facebook'" [sbUrl]="'https://www.facebook.com/facebook/'" (sbCount)="fbCount = $event"></div>
<h6 class="upload-social-followings">{{fbCount}}</h6>

Yet the h6 is empty. fbCount is undefined. What am I doing wrong here?

PS. I couldnt use
[{{ fbCount | nFormat }}
because fbCount is undefined and nFormat needs a number as an input

No errors in console.

from ngx-sharebuttons.

MurhafSousli avatar MurhafSousli commented on May 30, 2024

@karljv I'm showing you the usage code, and you are applying completely different code. but first:
1 - Don't shortcut pipe name!! use {{fbCount | nFormatter}} not {{ fbCount | nformat }}
2 - Please align your code, angular users should have the skills to align code in issues!

<div style="display: none" [shareButton]="'facebook'" [sbUrl]="someUrl" (sbCount)="fbCount = $event"></div>
<div class="fb-count">{{fbCount | nFormatter}}</div>

in your component

class someComponent{
   //
    fbCount: number = 0;
    someUrl = 'https://reddit.com'; //or any link you want
   //
}

Test the code by giving someUrl = 'https://reddit.com' to make sure the count is working first, then change it to whatever you want.

from ngx-sharebuttons.

karljv avatar karljv commented on May 30, 2024
  1. I used the correct name in code, it was a typo here.
  2. ok

New code

component.ts

export class ListingCreateComponent implements OnInit {
    // START - ShareButtons
    public fbCount: number              = 0;
    public facebookUrl                  = "https://www.facebook.com/facebook/"
    // END - ShareButtons

component.html

<div style="display: none;" [shareButton]="'facebook'" [sbUrl]="facebookUrl" (sbCount)="fbCount = $event"></div>
<h6 class="upload-social-followings">{{fbCount | nFormatter}}</h6>

The result is still a zero and I don't see any requests made in the network tab

from ngx-sharebuttons.

MurhafSousli avatar MurhafSousli commented on May 30, 2024

@karljv Did you see a number for [sbUrl]="'https://reddit.com'" ?

from ngx-sharebuttons.

karljv avatar karljv commented on May 30, 2024

Hmmm, it is still a 0 I'm afraid.

Maybe I am doing something else wrong.

The related imports in my component.ts are

import { ShareButtonsService, ShareButton, ShareProvider } from 'ng2-sharebuttons';

My module load order is

shared.module.ts

import { ShareButtonsModule }           from 'ng2-sharebuttons';

imports: [ ShareButtonsModule.forRoot() ...

is included in listings.module.ts

imports: [ SharedModule, ....

is included in app.module.ts
imports: [ ListingsModule, ....

Could the sharedmodule.forRoot(), that is included in not app.module.ts be a problem? I would like to keep app.module.ts as clean as possible, with only necessary submodules being loaded there.

from ngx-sharebuttons.

tinesoft avatar tinesoft commented on May 30, 2024

@karljv

Since the developer doesnt know his own plugin, I decided to go poking around the source code. He forgot to tell me that for the likes to be counted, you have to include the

[sbShowCount]="true"

on the damn directive

Please, be respectful when using an library someone spent his free time writing and decided to share.
Should i remind you this is an opensource project and that you don't pay anything for using it or for support.

The author did provide you with useful information in his post(the very same day!) , the documentation and demo application are pretty complete and we work hard to keep them update to date.

Please keep that in mind for next time.

Yours sincerely

from ngx-sharebuttons.

Related Issues (20)

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.