2
Does anyone know if there is a way to transfer the value of a variable to Ctrl+C?
I am working with Angularjs and inside Scope I have a variable that I would like to move to the Clipboard, but I can’t find anything that helps me.
Follows the code:
JS:
(function(){
'use script';
angular
.module('myApp')
.controller('meuCtrl', meuCtrl);
meuCtrl.$inject = ['$scope'];
function meuCtrl($scope){
$scope.grupos = [
{
"numero": 1,
"nome": "Grupo 1",
"link": "https://www.google.com/maps",
"visitado": true,
"data": "15/09/2017"
},
{
"numero": 2,
"nome": "Grupo 2",
"link": "https://mail.google.com/mail/u/0/#inbox",
"visitado": true,
"data": "15/09/2017"
}
]
$scope.copiar = function(teste) {
// aqui deve ser feita a atribuição
// clipboard = teste;
}
}
})();
Html:
<section ng-controller="meuCtrl">
<div ng-repeat="grupo in grupos">
<div ng-click="copiar(grupo.nome)">
<span>{{grupo.numero}}</span>
</div>
<div class="w3-container w3-button">
<a target="_blank" href="{{grupo.link}}"> <span>{{grupo.nome}}</span> </a>
</div>
</div>
</section>
When copying things from other developers cite sources https://stackoverflow.com/a/33928558/1518921, it’s not cool for you to take something done by another and not mention who had the work and still shared for free.
– Guilherme Nascimento
Hello William, really.. I had copied this answer for my use for some time. However I didn’t save the answer to make the link now. I’m sorry I forgot to make the quote at this time.
– Israel Merljak
I edited your answer, removing redundancies and adding the use of the script within the
scope
Angular, so help the author of the question ... if you disagree with something just do the rollback in the edition. See more.– Guilherme Nascimento