R
R
Roman Ogarkov2016-08-01 16:21:20
JavaScript
Roman Ogarkov, 2016-08-01 16:21:20

How to start an AngularJS application only after loading the start data from the server?

How to start an AngularJS application only after loading the start data from the server?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Nicholas, 2016-08-01
@ogarich89

Лучше всего для этого подойдет resolve в роутере.
Второй вариант - грузить данные и после этого бутстраппить ангуляр руками.

D
Dmitry Arushanov, 2016-08-01
@daruwanov

Получать данные в resolve ?

W
werevolff, 2016-08-01
@werevolff

And is it necessary? We do $scope.dataReady = false in the controller. The main container in HTML is ng-show="dataReady". After loading the data, switch $scope.dataReady. We hang

$scope.$watch('dataReady', function(newVal, oldVal) {
    if (newVal && !oldVal) {
       // А тут всё, что должно выполниться после загрузки данных. Но лучше вызвать отсюда сигнал.
    }
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question