ItSolutionStuff.com

How to Copy to Clipboard without Flash in AngularJS?

By Hardik Savani • October 20, 2023
jQuery Angular

In this post we are going learn how to copy to clipboard in AngularJS application using ngclipboard js plugin. I provide very simple example using CDN, so you can simply run and understand well.

when require to give function of copy some text by clicking on button or any link. There are several library can do copy text using flash player, but in this example i will do it without using flash player. In this example we will use

ngclipboard.js AngularJS Plugin for copy to clipboard.

Now i am going to share with you full example of ngclipboard js plugin. I use cdn for jquery and ngclipboard js that way you can run easily for testing. You can also see demo. So let's see bellow example:

Example:

<!DOCTYPE html>

<html>

<head>

<title>How to copy to clipboard without flash in AngularJS ?</title>

<script type="text/javascript" src="https://code.jquery.com/jquery-1.4.2.min.js"></script>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>

<script src="https://cdn.rawgit.com/zenorocha/clipboard.js/master/dist/clipboard.min.js"></script>

<script src="https://sachinchoolur.github.io/ngclipboard/dist/ngclipboard.min.js"></script>

</head>

<body>


<div class="container" ng-app="mainApp">


<!-- Target -->

<input id="foo" value="I am copied from ItSolutionStuff.com">


<!-- Trigger -->

<button class="btn" ngclipboard data-clipboard-target="#foo">Copy to clipboard

</button>


</div>


<script type="text/javascript">

var app = angular.module("mainApp", ['ngclipboard']);

</script>


</body>

</html>

For more information you can get from here : ngclipboard.js

I hope it can help you....

Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

AngularJS Scroll to a Specific Element using Anchorscroll

Read Now →

AngularJS Convert Comma Separated String to Array Example

Read Now →

AngularJS - How to Create Read More/Less Toggle using Directive?

Read Now →

AngularJS Nl2br Filter for Textarea Content Example

Read Now →

AngularJS Image Upload with Preview Example

Read Now →

How to Hide Div After Some Time in AngularJS?

Read Now →

How to Call Function on Page Load in AngularJS?

Read Now →

AngularJS Simple Datepicker Directive Example Tutorial

Read Now →

AngularJS Sorting(using Orderby Filter) Table Data Example

Read Now →

How to Change Date Format using Date Filter in AngularJS?

Read Now →

AngularJS - How to Limit String Length using Filter?

Read Now →

AngularJS - How to Capitalize the First Letter of Word Example

Read Now →

How to Remove HTML Tags from String in AngularJS?

Read Now →

PHP AngularJS CRUD with Search and Pagination Tutorial

Read Now →