Javascript 使用angualrjs向json ld添加数据

Javascript 使用angualrjs向json ld添加数据,javascript,json,angularjs,html,web,Javascript,Json,Angularjs,Html,Web,我是AngularJS的初学者,我被困在我的一个项目中。我希望用户在表单中输入的数据转换为格式:并在json ld的@graph中推送和显示。 这是我的html和angular代码: 角度模块(“手表”,[]) .controller(“ctrl”,函数($scope){ $scope.output={ “@context”:{ “架构”:http://schema.org/" }, “@graph”:[{ “@id”:“人”, “@type”:“schema:Person”, } ] } $

我是AngularJS的初学者,我被困在我的一个项目中。我希望用户在表单中输入的数据转换为格式:并在json ld的@graph中推送和显示。 这是我的html和angular代码:

角度模块(“手表”,[]) .controller(“ctrl”,函数($scope){ $scope.output={ “@context”:{ “架构”:http://schema.org/" }, “@graph”:[{ “@id”:“人”, “@type”:“schema:Person”, } ] } $scope.volatile={}; $scope.output[“@graph”][0][“schema:givenName”]=”; $scope.$watch(功能(范围){ 返回作用域.volatile }, 函数(newValue、oldValue){ $scope.output=newValue; }); })

头>
重新激活:角度测试


    • 吉文纳姆:
      家庭名称:
      性别:
      国籍:
      工作地点:
      职位名称:
      网址:
      图片:
      你的JSON {{output}}

$scope.output['@graph'].push({
        "@id": "person",
        "@type": "schema:Person",
        });