Lukas Podolski Lukas Podolski - 2 months ago 6
Javascript Question

Concat string in $scope angularjs

I want to pass string name through argument in function and concat in $scope, this is possible?

function test(txt){
$scope.person. + txt; // I want to do $scope.person.status; for example
}


Thanks.

Answer

Yes, just do:

function test(txt){
   $scope.person[txt];
}
Comments