angularjs - json value getting it as "[object Object]" -
in angularjs ng-route since params dynamic i'm passing json shown below
$scope.filmnames= { 'films': { 'film': [{ filmname: 'abcd', filmyear: '123' }, { filmname: 'bcd', filmyear: '145' }, { filmname: 'def', filmyear: '128' }] } }; '.../index.html#/admin?jsonobj='+$scope.filmnames ans succesffully sending like
http://localhost:8000/index.html#/admin?jsonobj=[object object] but @ controller receiver when tried through using $routeparams like
var jsonobj= $routeparams.jsonobj; console.log(json.stringify(jsonobj)); it been printing "[object object]", instead of values
can please tell me solutions this
when convert object string using concatentation, get: [object object]. want convert object json.
'.../index.html#/admin?jsonobj='+json.stringify($scope.filmnames) then, @ receiver, you'll want parse it, not stringify it.
console.log(json.parse(jsonobj)); i suggest moving away calling json strings "json objects", leads confusion. json strings don't represent objects.
Comments
Post a Comment