2016-07-09 4 views
0

dies ist mein Controller in AngularJSAngularjs: 13708 Syntaxerror: unerwartete Token p in JSON an Position 130

(function(){ 
 
    "use strict"; 
 
    angular 
 
     .module("testApp") 
 
     .controller("testAppCtrl", function($scope , $http){ 
 
      $http.get('/data/testapp.json').then(function(data){ 
 
       //$scope.testapps = testapp.data; 
 
       console.log(data); 
 
      }); 
 
     }); 
 
})();

und i Gesicht Diese Fehler

angular.js:13708 SyntaxError: Unexpected token p in JSON at position 130 

wie Kann ich es reparieren?

+4

Teilen Sie die JSON von '/ data/testapp.json' mit uns. Meine Vermutung ist, dass es ein unerwartetes Token "p" an Position 130 gibt. –

+0

Bitte teilen Sie die JSON – htoniv

Antwort

0

Ihre JSON-Datei enthält ungültige code.You fehlen quots um geschrieben und Kontakt auch im und extra eingeführt wird dies wie

sein sollte
[{ 
"id": "1", 
"title": "test1", 
"description": "test 1 test 1 test 1 test 1 test 1 ", 
"price": "2000", 
"posted": "2015-10-24", 
"contact": { 
    "name": "test1 mona", 
    "phone": "98765678", 
    "email": "[email protected]" 
}, 
"categories": [ 
    "vehicle", 
    "test" 
], 
"image": "1.jpg", 
"views": "200" 
}, { 
"id": "2", 
"title": "test2", 
"description": "test 2 test 2 test 2 test 2 test 2 ", 
"price": "2000", 
"posted": "2015-10-24", 
"contact": { 
    "name": "test2 mona", 
    "phone": "98765678", 
    "email": "[email protected]" 
}, 
"categories": [ 
    "vehicle", 
    "test" 
], 
"image": "1.jpg", 
"views": "200" 
}, { 
"id": "3", 
"title": "test3", 
"description": "test 3 test 3 test 3 test 3 test 3 ", 
"price": "3000", 
"posted": "2015-10-24", 
"contact": { 
    "name": "test3 mona", 
    "phone": "98765678", 
    "email": "[email protected]" 
}, 
"categories": [ 
    "vehicle", 
    "test" 
], 
"image": "1.jpg", 
"views": "100" 
}, { 
"id": "4", 
"title": "test4", 
"description": "test 4 test 4 test 4 test 4 test 4 ", 
"price": "4000", 
"posted": "2015-10-24", 
"contact": { 
    "name": "test4 mona", 
    "phone": "98765678", 
    "email": "[email protected]" 
}, 
"categories": [ 
    "vehicle", 
    "test" 
], 
"image": "1.jpg", 
"views": "40" 
}, { 
"id": "5", 
"title": "test5", 
"description": "test 5 test 5 test 5 test 5 test 5 ", 
"price": "5000", 
"posted": "2015-10-24", 
"contact": { 
    "name": "test5 mona", 
    "phone": "98765678", 
    "email": "[email protected]" 
}, 
"categories": [ 
    "vehicle", 
    "test" 
], 
"image": "1.jpg", 
"views": "290" 
}, { 
"id": "6", 
"title": "test6", 
"description": "test 6 test 6 test 6 test 6 test 6 ", 
"price": "6000", 
"posted": "2015-10-24", 
"contact": { 
    "name": "test6 mona", 
    "phone": "98765678", 
    "email": "[email protected]" 
}, 
"categories": [ 
    "vehicle", 
    "test" 
], 
"image": "1.jpg", 
"views": "10" 
}] 
+0

Wenn Sie Ihre JSON-Datei validieren möchten, folgen Sie diesem Link http://jsonlint.com/ – jitender

Verwandte Themen