json - AngularJS "$resource:badcfg" Error -
I am facing a very strange error, though I think it is easy to decide, I think Code Solution: Code: Summary: An AJAX request is sent to the server, which uses NG-resource to retrieve data that is JSON's Form is formatted. When a single JSON object occurs, it works fine, for example, when I have multiple JSON objects:
{"letters": [{}], "the word ": [{}}} This throws badcfg error.
I do not understand how to solve it further.
app.factory 'getWords', [' $ resource ', function ($ resource, $ cachefactory) {return: {resource: (resource /' lane / api / meet / word / letter ', {letter:' @letter '}, {' receive ': {method:' GET ', cache: $ cacheFactory},' query ': {method:' get ', isArray: false, fomrat:' JSON ' }})}])); I am using this service to trigger and the code to access that data is:
$ scope.words = getWords .all.query ({letter: $ Scope.letter}); console.log ($ scope.words); console.log ($ scope.words.words); I hope I am clear, thank you
if Nobody is going through this clear puzzle, do not fear the solution is something simple, after some hair graying, it seems that all you have to do is make sure that the ARRA is wrong (in my case, I Wrong method set to false).
Then when you are calling that service, make sure you use the (callback?) Function that grabs back the returned data and allows you to use objects in it . Maybe another experienced programmer could explain to me what I'm trying to say better than me :)
Here's working on:
app.factory ('getWords' [' $ resource ', function ($ resource, $ cacheFactory) {returns {all: $ resource (/ lane / API / getWords /: letter', {letter: '@letter' }, {'Get': {method: 'resource' ('/' word / word / word / word / word: word '', cache: $ cacheFactory}, 'query': {method: 'gET' Cache: $ cacheFactory, isArray: false}}, {word: '@word'}, {go '}: {met hod:' gET ', cache: $ cacheFactory},' query ': {method:' GET ' , cache: $ ca cheFactory, isArray: true}})}}])); And when you want to get data through this service (getWords)
getWords.all.query ({letter: $ scope.letter }, Function (data) {$ scope.words = data.words;}); Thanks for all help
Comments
Post a Comment