Mahamadou Taibou Mahamadou Taibou - 5 months ago 8
AngularJS Question

Angular js how to use scope data in a scope array. The proper way

I'm facing some kind of trouble. How can I do this?

$scope.data = {
a: $scope.a,
b: $scope.b
}


I got undefined. I need those scopes in the data scope.

Answer

hi u can do like that can store a scope inside in your data object check this

JS

$scope.name = 'World';
  $scope.name2 = 'World';
  $scope.data = {
   a:  $scope.name,
   b: $scope.name2
}
console.log($scope.data)
console.log($scope.data.a)
console.log($scope.data.b)