如何创建以下类型的 json,这将有助于使用 angular js 提前输入
How to create following type of json that will usefull in type ahead with angular js
我已经使用 codepen
.
使用 angular js 成功实现了提前输入
现在我的数据是动态的,所以我想创建自己的 json,它应该类似于以下内容:
$scope.states = [
{
name: "ABCD",
id: "AB"
},
{
name: "XYZ",
id: "XY"
},
{
name: "OPQR",
id: "OP"
},
{
name: "LMNO",
id: "LM"
},
{
name: "KLM",
id: "KL"
}
];
如何像上面那样创建 json 并存储在 $scope 变量中,以便我可以分别使用名称和 ID 访问它。
请帮帮我...!!
我现在自己给,因为我有点晚了。
解决方法是我把数据推错了我已经解决了:
$scope.states.push({
name: "string",
id: int,
});
我明白了。
我已经使用 codepen
.
现在我的数据是动态的,所以我想创建自己的 json,它应该类似于以下内容:
$scope.states = [
{
name: "ABCD",
id: "AB"
},
{
name: "XYZ",
id: "XY"
},
{
name: "OPQR",
id: "OP"
},
{
name: "LMNO",
id: "LM"
},
{
name: "KLM",
id: "KL"
}
];
如何像上面那样创建 json 并存储在 $scope 变量中,以便我可以分别使用名称和 ID 访问它。
请帮帮我...!!
我现在自己给,因为我有点晚了。
解决方法是我把数据推错了我已经解决了:
$scope.states.push({
name: "string",
id: int,
});
我明白了。