繁体   English   中英

如何使用 Angular 在社交网站中共享自定义文本

[英]How to share Custom Text in social website using Angular

我有JwSocialButtonsModule用于我的社交分享。
JwSocialButtonsModule在我的应用程序模块中

我的代码:

<div class="jumbotron">
<div class="row">
    <div class="col">
        <fb-like url={{url}}></fb-like>
    </div>
    <div class="col">
        <google-plus url={{url}}></google-plus>
    </div>
    <div class="col">
        <tweet url={{url}} text={{text}}></tweet>
    </div>
    <div class="col">
        <linkedin-share url={{url}}></linkedin-share>
    </div>
    <div class="col">
        <pin-it url={{url}} media={{imageUrl}} description={{text}}></pin-it>
    </div>
</div>

我需要共享自定义文本而不是 url。 如果我将 url 更改为文本其抛出错误,例如

模板解析错误:

Can't bind to 'text' since it isn't a known property of 'fb-like'.
1. If 'fb-like' is an Angular component and it has 'text' input, then verify that it is part of this module.
2. If 'fb-like' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

如何通过社交分享分享文字内容

闪电战链接

请尝试使用此方法在 url 之间添加自定义文本

试试这个在 url 之间添加自定义文本

 window.open('https://twitter.com/intent/tweet?text=%20Check%20up%20this%20awesome%20content' + encodeURIComponent(document.title) + ':%20 ' + encodeURIComponent('https://freadee.com/#/food/detail/' + this.shareFoodId + 'add custom text here'));

.html

 <div class="modal-body text-center"> <!-- Add font awesome icons --> <!-- <share-buttons show="11"></share-buttons> --> <a class="social-icon social-icon-facebook fab fa-facebook-f m-1" href="https://www.facebook.com/sharer/sharer.php?u=&t=" title="Share on Facebook" target="_blank" (click)="sharefacebookUrl(foodid)"></a>&nbsp; <a class="social-icon social-icon-twitter fab fa-twitter m-1" href="https://twitter.com/intent/tweet?" target="_blank" title="Twitter" (click)="sharetweetUrl(foodid)"></a>&nbsp; <a class="social-icon social-icon-envelope fas fa-envelope m-1" href="mailto:?subject=&body=:%20" target="_blank" title="Email" (click)="sharemailUrl(foodid)" click=""></a>&nbsp; <a class="social-icon social-icon-instagram fab fa-instagram m-1" href="https://instagram.com/accounts/login/?" target="_blank" title="Instagram" (click)="shareinstaUrl(foodid)"></a>&nbsp; </div>

.ts

 sharefacebookUrl(foodid) { this.shareFoodData = foodid this.shareFoodId = foodid.food_id this.share(); // window.open('https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent('https://freadee.com/#/food/detail/' + this.shareFoodId+ 'add custom text here')); return false } sharetweetUrl(foodid) { window.open('https://twitter.com/intent/tweet?text=%20Check%20up%20this%20awesome%20content' + encodeURIComponent(document.title) + ':%20 ' + encodeURIComponent('https://freadee.com/#/food/detail/' + this.shareFoodId+ 'add custom text here')); return false; } sharemailUrl(foodid) { window.open('mailto:?subject=' + encodeURIComponent(document.title) + '&body=' + encodeURIComponent('https://freadee.com/#/food/detail/' + this.shareFoodId+ 'add custom text here')); return false; } shareinstaUrl(foodid) { window.open('https://instagram.com/accounts/login/?text=%20Check%20up%20this%20awesome%20content' + encodeURIComponent(document.title) + ':%20 ' + encodeURIComponent('https://freadee.com/#/food/detail/' + this.shareFoodId+ 'add custom text here')); return false; }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM