Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Iterate json data in angularJS

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 347
    Comment on it

    While working for an autocomplete funtionality in angularJS encountered a problem where instead of the JSON we need to iterate each element and have to make an Array of string.

    For iterating the JSON data(from server side), we used:

    $scope.complete = function(){
       $ =;
                //we can use function(item) instead of function(item, index) if index number is not required
       angular.forEach($, function(item, index){
            $scope.values[index] = item.data1+","+item.data2;
       $("#suggestion").autocomplete({ source: $scope.values });

    Here scope.values is array of string, where we have put all the data.

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: