1

Can I have some JSON object that is employes.json file for example:

{"employees":[
    {"firstName":"John", "lastName":"Doe"},
    {"firstName":"Anna", "lastName":"Smith"},
    {"firstName":"Peter", "lastName":"Jones"}
]}

And than use that object inside of a script where angular.js is? In other words how can I invoke predefined object in angular file and parse it?

3
  • The question is very unclear. Please add a full minimal reproducible example that represents your situation. Commented Sep 1, 2016 at 8:48
  • this object is in json file ? Commented Sep 1, 2016 at 8:50
  • make a $http service call to the json file and on success response parse the json object. Commented Sep 1, 2016 at 9:30

1 Answer 1

5

Just load it using $http service, for example

$http.get(url).then(function(response){
   // here response.data will be parsed JS object
});
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.