1

I have a JSON array of arrays like this:

[["[email protected]","joe"], ["[email protected]","brain"], ["[email protected]","bob"]]

How can I get the values separately?

<div class="item item-divider item-input-wrapper">
    {{ email should be here }} : {{ name here }}
</div>          

I need the email and name separately, but it's not displaying anything.

2 Answers 2

2

Here is a fiddle: http://jsfiddle.net/sinaidoron/1c12r4hr/2/ Its one possible way of doing that

var myApp = angular.module('myApp',[]);


function MyCtrl($scope) {
    var persons = [["[email protected]","joe"],["[email protected]","brain"],["[email protected]","bob"]];

    var newPersons = [];
    for(var i=0; i< persons.length; i++){
        var tempObj = {};
        tempObj.email = persons[i][0];
         tempObj.name = persons[i][1];
        newPersons.push(tempObj);
    }
console.log(newPersons)
    $scope.persons = newPersons;

}

<div ng-controller="MyCtrl">
    <div ng-repeat="person in persons">
        {{person.email}} {{person.name}}
    </div>
</div>
Sign up to request clarification or add additional context in comments.

Comments

1

Controller:

$scope.data = [["[email protected]","joe"],["[email protected]","brain"],["[email protected]","bob"]];

Html:

<div class="item item-divider item-input-wrapper" ng-repeat="each in data">
  {{ each[0] }} : {{ each[1] }}
</div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.