我有一个对象数组,显示在我的作用域中,一旦通过两个下拉选择框选择,第一个框选择第二个选择格式的名称。一个对象的从角度范围获取ID值并用于陈述
例如
{
"name": "tim",
"format": [
{"Fname": "a", "id": "1"},
{"Fname": "b", "id": "2"},
{"Fname": "c", "id": "3"}
]
},
,我将其发送到使用
$scope.productTypeChange = function() {
$scope.formats = $scope.productsandformats.find(ps => ps.name == $scope.formData.ProductType.name)
}
我得到一品脱了我的范围,想
{"ProductType":{"name":"tim"},"formatType":{"Fname":"a","id":"1"}}
那么我想有范围一个if语句基于在范围中打印的ID值,我已经尝试过以获得ID值,但它看起来似乎不起作用,Is这是获取ID的正确方法>
$scope.setCanvasSize = function() {
divHeight = $('.image-builder').height();
if ($scope.formData.ProductType.name.id = 1) {
// Aratio = 0.67;
Aratio = 2;
} else if ($scope.formData.ProductType.name.id = 2) {
Aratio = 0.56;
} else if ($scope.formData.ProductType.name.id = 3) {
divHeight = divHeight/1.5;
Aratio = 2;
} else if ($scope.formData.ProductType.name.id = 4) {
Aratio = 0.67;
} else {
Aratio = 1
}
canvas.setHeight(divHeight - 15);
canvas.setWidth((divHeight - 15) * Aratio);
canvas.renderAll();
$scope.position();
};
问题是什么? – Vivz
Il为你和其他人更新问题 – Beep
你想获得ID吗? – Vivz