0

Am new to Angular JS. Am working on messaging. Am stuck with this point. I have following ng-repeat structure.

<div ng-repeat="x in MessageUserList | filter:curPlace">  
  <textarea class="form-control" id="message" ng-model="user.message"></textarea>
  <button type="submit" class="btn btn-sm btn-primary m-t-n-xs" 
  ng-click="SendMessage(myData.member_id,x.member.member_id);">Send message           
  </button>
</div>

.

MessageUserList JSON data is:

[{ "member":{"member_id":23, "first_name":"Suyash", "middle_name":"Jamesh", "last_name":"Jamesh", "joining_date":"02-06-2017", "phone":7411556977 so on.... }]

User photo and name is coming dynamically from web service Am passing myData.member_id and x.member.member_id as parameter when I click on Send Message button. Now at the same time I want to pass text area value also to a controller. I used deep copy. But it is not working.

My controller is:

$scope.SendMessage = function(user_id,to_whom_sen_id) { 
   $scope.user_id = user_id;
   $scope.to_whom_sen_id = to_whom_sen_id;
   var r = angular.copy(user, $scope.message);
   alert(r); //Not working
};
Prashanth Harish
  • 158
  • 1
  • 1
  • 17

2 Answers2

0

ng-model for your textarea is user.message, then in angular.copy it should be

var r = angular.copy($scope.user.message);

hope it would help.

the_mishra
  • 813
  • 9
  • 24
0

Try this

<textarea class="form-control" id="message" ng-model="message"></textarea>
ninhjs.dev
  • 7,203
  • 1
  • 49
  • 35