Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

Well i have a problem and i would like to know if someone give me an advice.

I want to call the child called File1 using ng-if.

well i want to access inside file1's data.

ang.js

var app = angular.module('app', [])
app.controller("ctrl", function ($scope, $http) {
    $scope.files = [];
    var promise = $http.get("link1")
        .then(function (response) {
            console.log(response);
            $scope.getfiles = response.data;
            return $http.get('link2', {
                params: {
                    id: response.data[0].Id
                }
            })
        })
    .then(function (response2) {
        console.log(response2);
        $scope.files = response2.data;
        return response2.data;
    })
})

Index

    <body ng-app='app'>
<div ng-controller='ctrl'>
            <span ng-repeat="get in files">
        {{get.files}}
            <span ng-if="get.Id== 10303">
                <span ng-repeat="child in get.File1">
                    {{ child.Id}}
                </span>
            </span>
        </span>
</div>
    </body>

What's my mistake?, I'm newbie in AngularJs

share|improve this question
    
do console.log(JSON.stringify(response)) & console.log(JSON.stringify(response2)) and include the text in your question instead of a screen shot – Professor Allman Jun 10 at 3:03
    
the text in my question, what do you mean? The screenshot was an example. – DaemonTools Jun 10 at 3:09
    
when you do console.log(JSON.stringify(response)) it will create a serialized text representation of the response object. Copy the text from the console and paste it into your question. – Professor Allman Jun 10 at 3:10
    
if all response data is correct, what error its showing when accessing? – Neha Jun 10 at 3:33
    
It isn't an error, it just doesn't show the children's data. – DaemonTools Jun 10 at 3:43

You need to mention which controller to use to start with. Debug your code to see if http request is giving correct response back. Then focus on the part of displaying it.

share|improve this answer
    
I'm using one controller called 'ctrl'. – DaemonTools Jun 10 at 3:19
    
Please create a jsfilddle for your code. That way people will be able to look at Working code. – Arpit Jun 10 at 3:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.