0

I am building an app that is supposed to guide a customer through a series of questions to get the proper product depending on the customers needs.

The app needs to make a JSONP call to an API call to get the data for products and questions, and the whole app is dependent on this data.

Does Angular have any kind of support for this scenario? Preferably I don't even want to start the app until the data has arrived, only showing a loading screen or something similar.

I have tried to make a JSONP call and doing the ng.module('myApp') in the callback, but then I get some Angular errors because the module 'myApp' doesn't exists yet (since Angular will boot up before the JSONP call is back).

What can I do?

Thanks in advance

Emil
  • 1,035
  • 3
  • 10
  • 19

1 Answers1

1

In the controller :

$scope.data = null;
$http.jsonp(...).success(function(data) { $scope.data = data; });

And in the view:

<div ng-show="!data">Loading...</div>
<div ng-show="data">Show the questions here</div>
JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • Thanks! But then I'll have to do it in each controller, right? Maybe that is how it's going to be done. – Emil Aug 22 '13 at 11:09