我與JS角小的項目工作(PS:這是我第一次使用它),我的這個錯誤阻止,我不明白爲什麼角JS項目不工作
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"] = "";
}
*「被此錯誤阻止」* ..什麼錯誤? – dfsq
oh sorry0thsi one:「無法設置屬性'架構:未定義的familyName' – user3430205
您在數組''@graph」'中只有一個元素。所以'$ scope.personld [「@ graph」] [1]'確實是未定義的。你可能想要'$ scope.personld [「@ graph」] [0] [「schema:familyName」] =「」' – dfsq