Comments (10)
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.
@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.
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.
@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.
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.
@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.
- I used the correct name in code, it was a typo here.
- 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.
@karljv Did you see a number for [sbUrl]="'https://reddit.com'"
?
from ngx-sharebuttons.
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.
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)
- instagram button
- gmail button is not available HOT 1
- When click on Messenger and Viber nothing happens, link doesn't open HOT 1
- setting meta tags doesn't seem to matter? HOT 4
- Share via Mastodon HOT 1
- how to add role to given tag HOT 2
- Opened output not firing HOT 3
- Whatsapp redirection to 'api/web .whatsapp.com' controlled manually HOT 1
- :bug: v12.0.0 says tumblr and reddit are no longer available to use with shareButton directive
- can we open shared details in pop up instead of new tab ? HOT 2
- i am geting error with Angualr version 15 HOT 6
- How to use share buttons vertically? HOT 1
- share-buttons inputs don't work within square brackets. HOT 1
- add or replace twitter option for X HOT 5
- Unable to share image HOT 1
- Can't install; error with cdk version HOT 1
- Required Old Twitter Logo Update | 'X' HOT 2
- Updating to Angular 17 HOT 4
- share my articles in linkedin with preview image HOT 2
- ngx-sharebuttons for angular 9.1.3 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngx-sharebuttons.