我有三个产品数组和一个变量来保持当前的一个作为选择:
product_types=['One', 'Two', 'Three']
product_type_one = [
{'description': 'Type one sample one', 'type': 'one'},
{'description': 'Type one sample two', 'type': 'one'},
{'description': 'Type one sample three', 'type': 'one'},
]
product_type_two = [
{'description': 'Type two sample one', 'type': 'two'},
{'description': 'Type two sample two', 'type': 'two'},
{'description': 'Type two sample three', 'type': 'two'},
]
product_type_three = [
{'description': 'Type three sample one', 'type': 'three'},
{'description': 'Type three sample two', 'type': 'three'},
{'description': 'Type three sample three', 'type': 'three'},
]
selectedProduct=null;
在我的模板上,我填充单选按钮,以便用户可以选择以下产品组之一:
<div class="my-filters" *ngFor="let product of product_types">
<mdl-radio
name="productgroup"
value="product"
ngModel='selectedProduct'
(change)="showProduct(product)"
mdl-ripple>{{product}}</mdl-radio>
</div><br>
<mdl-card *ngFor="let product of selectedProduct" class="demo-card-event" mdl-shadow="2">
<mdl-card-title mdl-card-expand>
<h4>
{{product.description}}
</h4>
</mdl-card-title>
<mdl-card-actions mdl-card-border>
<button mdl-button mdl-colored mdl-ripple (click)="openDialog()">
view
</button>
<mdl-layout-spacer></mdl-layout-spacer>
<mdl-icon>shopping_cart</mdl-icon>
</mdl-card-actions>
</mdl-card>
直到这里,无论用户点击什么单选按钮,都会在我的mdl卡中填充正确的数组,但用户点击的所有单选按钮仍会被点击,而不仅仅是当前的选择:
我做错了什么?
答案 0 :(得分:0)
您应该使用import UIKit
import Vision
class ImageTranslation {
func translateImages(for referenceImage: UIImage,
floatingImage: UIImage,
complete: @escaping (UIImage) -> Void) {
let translationRequest = VNTranslationalImageRegistrationRequest(targetedCGImage: floatingImage.cgImage!, completionHandler: self.handleImageTranslationRequest)
let vnImage = VNSequenceRequestHandler()
try? vnImage.perform([translationRequest], on: referenceImage.ciImage!)
}
func handleImageTranslationRequest(request: VNRequest, error: Error?) {
var alignmentTransform: CGAffineTransform!
if let results = request.results as? [VNImageTranslationAlignmentObservation] {
results.forEach { result in
alignmentTransform = result.alignmentTransform
print(alignmentTransform)
}
}
}
}
进行分组,如下所示
md-radio-group
答案 1 :(得分:0)
我更新了我的for循环,如下所示:
<div *ngFor="let product of product_types" class="my-filters">
<mdl-radio name="productgroup" [value]='product' [(ngModel)]="selectedProduct" (change)="showProduct(product)"> {{product}} </mdl-radio> <br>
</div>