我有一個對象數組,顯示在我的作用域中,一旦通過兩個下拉選擇框選擇,第一個框選擇第二個選擇格式的名稱。一個對象的從角度範圍獲取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