view raw
Abhijars Abhijars - 7 months ago 30
AngularJS Question

How to append object field value as string in textarea on clicking particular object field using angular js

i want to append object value to textarea on clicking on particular object field of ng-repeat.

<div ng-repeat="list in listing">
<a href="">{{}}</a>

var myApp = angular.module('myApp', []);

myApp.controller('Main', function($scope){

$scope.listing = [{id :"1", name:"one"},{id :"2", name:"two"},{id :"3", name:"three"}];
$scope.complaint = "";



Create a function to do the adding in your controller, for example:

$scope.addToTextArea = function(item) {
    var newline = String.fromCharCode(13, 10);
    $scope.complaint += + newline;

and hook into this using the ng-click directive:

<a href="" ng-click="addToTextArea(list)">{{}}</a>