0

I am new in angularjs.

I have a directive that uses a promise to get a remote json to generate the template. The directive renders table columns.

I have a table with a controller that get remote data using a promise.

How can I be sure that the template that renders the columns is ready before the table try to render data?

1 Answer 1

1

You can have one or both promises in the Parent and use binding to send a reference of the promise to the child:

Plunker

app.directive('parent', function () {
    return {
        restrict: 'E',
        controller: function ($scope, $q) {
            $scope.tablePromise = $q.when();
        }
    }
});

app.directive('child', function () {
    return {
        restrict: 'E',
        scope: {
            promise: '='
        },
        controller: function ($scope) {
            $scope.promise.then(renderColumns)
        }
    }
});
Sign up to request clarification or add additional context in comments.

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.