我正在尝试创建一个对象数组并将其存储在名为chats(暂时名称)的变量中,该变量包含具有多个属性的对象:'id','symptom'和'diagnosis'。 “id”和“症状”属性完美无缺,但“诊断”属性存在问题。我想创建app用户为服务汽车需要采取的逐步说明列表。我的第一个想法是创建一个步骤数组并将该数组分配给'诊断'属性,但运行时,应用程序将代码显示为单个段落,而不是子弹/列表。我的第二个目标是使用ng-repeat来完成数组中每个对象的每个诊断步骤,因为最终的数组中有60多个对象,每个对象具有不同数量的服务步骤,如下所示。
<script>
<!-- An array of objects stored as an array in the variable chats -->
var chats = [{
id: 0,
symptom: 'WHEN THE CAR WILL NOT START/THERE IS NO POWER',
<!-- For this diagnosis object property, the goal was to have some sort of list so I can ng-repeat through each step for every object in the chats array. I tried to create an array for this property but it didn't work as I intended -->
diagnosis:
[
'Check the battery',
'Make sure the battery terminals are clean',
'Check the water level in the battery',
'Check where the battery cable connects',
'Check for blown fuses',
'Make sure the battery is charged',
'Check starter connections'
]
},{
id: 1,
symptom: 'WHEN THERE IS A CLICKING SOUND',
diagnosis:
[
'Check the items above',
'Check the starter relay'
]
}];
</script>
<html> <!-- Below is what is show on screen when the app is run on an emulator -->
["Check the battery","Make sure the battery terminals are clean","Check the water level in the battery","Check where the battery cable connects","Check for blown fuses","Make sure the battery is charged","Check starter connections"]
</html>