Amila Sampath
Amila Sampath

Reputation: 645

Update array value in angularjs

This is my Sample code :

var array_03 = [{'name':'Kapila','age':30}];
var array_04 = [{'name':'Saman','age':30}];    
$scope.userName_03 = array_03[0]['name']; // Kapila
$scope.userName_04 = array_04[0]['name']; // Saman
angular.isArray(array_03); // true
angular.isArray(array_04); // true

array_04[0]['name'] == $scope.userName_03; // <-- Problem here     

$scope.userName_05 = array_04[0]['name']; // <-- Hope to get 'Kapila' But Result 'Saman'

I Hope to $scope.userName_05 as 'Kapila' But Result 'Saman'

array_04[0]['name'] == $scope.userName_03; // <-- Problem here

Upvotes: 0

Views: 65

Answers (1)

Joomler
Joomler

Reputation: 2798

array_04[0]['name'] == $scope.userName_03; // <-- Problem here 

In this line use '=' instead of '==' You are assigning the value so it must be '=' (assignment operator)

Upvotes: 4

Related Questions