I have an array of objects iterated over in a list. If I click on the name, it should alert me with the value of the city the name corresponds to.
<div ng-app='myApp'>
<div ng-controller="AppController">
<div ng-click="getCity()" ng-repeat="step in steps">
<p> {{step.name}}</p>
</div>
</div>
var myApp = angular.module('myApp', []);
myApp.controller('AppController', function ($scope) {
$scope.steps = [
{name: "ABC", status: true, city: "Boston"},
{name: "DEF", status: true, city: "New York"},
{name: "GHI", status: true, city: "LA"}
];
$scope.getCity = function(a) {
}
});
--> So I click on "ABC" and "Boston" should be shown to me.
Appreciate the help. Thanks.