[英]angular js project not working
我正在開發一個帶有角度js的小項目(ps:這是我第一次使用它)而且我被這個錯誤阻止了,我不明白為什么
angular.module("jsonerator", [])
.controller('theController', function ($scope) {
$scope.personld = {
"@context": {
"schema": "http://schema.org/"
},
"@graph": [
{
"@id": "person",
"@type": "schema:Person",
}
]
}
$scope.personld["@graph"][0]["schema:givenName"] = "";
$scope.personld["@graph"][1]["schema:familyName"] = "";
}
要修復錯誤,您需要在@graph數組中添加另一個對象,它應該可以正常工作。 然后定義["@graph"][1]
。 問題是你的數組中只有一個項目。
"@graph": [
{ "@id": "person", "@type": "schema:Person" },
{}
]
@graph
數組的長度只有1個元素,因此$scope.personld["@graph"][1]
不存在,命令$scope.personld["@graph"][1]["schema:familyName"] = "";
拋出錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.