Z
Z
zdiii2015-12-31 23:06:22
PHP
zdiii, 2015-12-31 23:06:22

How to do this in Angular?

Happy New Year!
How would such PHP code be in Angular?

<?
$array = array('one' => array('name'=>'Маша'));
$b = 'one';
echo $array[$b]['name']; //Маша
?>

Angular
...
$scope.array= [{'one': { name: 'Маша'}}];
$scope.b = 'one';
alert(/* Здесь как? */ );
...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
cha-cha, 2015-01-01
@zdiii

alert($scope.array[0][$scope.b].name);

E
Eugene, 2015-12-31
@Eugene_H

is the top code in laravel or joomla?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question