Join the Stack Overflow Community
Stack Overflow is a community of 6.8 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I currently I have this way to get a JSON list.

function ()
{
    return $http
    (
        {
            url: '../Content/Scripts/Languages/en.json',
            method: "GET",
            headers:
            {
                'Content-Type': 'application/json; charset=utf-8'
            }
        }
    );
},

The reason I don't want to use a GET method is because it works as a promise, and because of that, any function that happens after the promise will execute, and if the list that I retrieve from there is empty will make the app crash.

So what I want is retrieve the list and after that, the rest of my functions can execute with a List filled.

Any suggestions?

share|improve this question
    
You could use callback functions to perform actions in case of success or error. – deez4h Nov 23 '15 at 23:20
    
I believe that is a promise... and I'm using those promise.success ( function (data) { $scope.Concepts = data; } ) .error ( function (errorMessage) { //Something } ); – Victor Nov 23 '15 at 23:33
1  
Embrace promises :) – Steve Campbell Nov 23 '15 at 23:56

You can use RequireJS for this.

You will need just this:

define('yourModuleWithNgApplication', ['json!path/to/json/file.json'], function (json) {
   // here you can access json variable, it will contain content of file.json
});
share|improve this answer

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.