i am using wordpress rest api v2 for getting data from my working wordpress website to angularjs application. all is working fine but when i want to use post meta like "_ait-item_item-data". its return me an error "undefined".
i am using his code to get post meta :
$scope.fieldOne = $scope.businessDetails.post_meta_fields._ait-item_item-data;
and i want to print:
{{fieldOne}}
i know that the problem with underscore and hyphen but how can i get the meta data with them ?
this is the error in console:
ReferenceError: item_item is not defined
at itemSingleCtrl.js:13
at angular.js:16170
at m.$eval (angular.js:17444)
at m.$digest (angular.js:17257)
at m.$apply (angular.js:17552)
at l (angular.js:11697)
at K (angular.js:11903)
at XMLHttpRequest.y.onload (angular.js:11836)
Since your property contains -
in it, you can't use dot notation to access its value. You have to access it like below
$scope.fieldOne = $scope.businessDetails.post_meta_fields["_ait-item_item-data"]