如何在angularjs中实现链接预览

问题描述 投票:3回答:1

angularjs中是否有任何指令来实现angularjs中的链接预览。我需要在我的网站上共享链接时显示链接预览,类似于google plus。

有一些指令https://github.com/LeonardoCardoso/Link-Preview。但它使用PHP。我需要没有PHP。

angularjs hyperlink
1个回答
0
投票

如果您在材料设计中使用Angular,则可以使用以下内容:

https://github.com/angular-material-extensions/link-preview

此外,您始终可以使用以下方式手动执行:免费链接预览服务

http://linkpreview.net是一个免费的REST API服务,它将任何URL作为输入,并发回带有标题,描述和缩略图的JSON响应。

您需要做的就是向API发送请求,其中包含必须生成链接预览的URL。

这是一个示例请求(GET)

http://api.linkpreview.net/?key=123456&q=https://www.google.com

响应:

{
"title": "Google",
"description": "Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.",
"image": "http://www.google.com/images/branding/googlelogo/1x/googlelogo_white_background_color_272x92dp.png",
"url": "https://www.google.com/"
}

您可以解析响应并设置样式。

© www.soinside.com 2019 - 2024. All rights reserved.