如何在点击单选按钮时过滤let url = URL(fileURLWithPath: "URL String Here")
let activityViewController = UIActivityViewController(activityItems: [url], applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = controller.view // so that iPads won't crash
controller.present(activityViewController, animated: true, completion: nil)
?
例如: - 在plunker中我们使用category values
显示了类别值。有两个单选按钮,data-ng-bind
1.Moral Ethics
。如果我们点击2. Religion & Culture
的第一个单选按钮,它应moral ethics
仅filter
,如果我们点击moral ethis values
它的第二个单选按钮应religon & Culture
仅filter
。
我的HTML单选按钮: -
religon & Culture values
我的HTML过滤器: -
<div class="col-md-3">
<label class="green"><input type="radio" name="myquestion" data-ng-model="myquestion.category" value="myquestion" ><span>Moral Ethics</span></label>
</div>
<div class="col-md-3">
<label class="green"><input type="radio" name="culture" data-ng-model="culture.category" value="culture" ><span>Religion & Culture</span></label>
</div>
我的Html数据:
ng-repeat="question in questions | filter: myquestion | filter:culture"
我的控制器数据: -
<div ng-repeat="question in questions | filter:myquestion | filter:culture">
<small>
<span >{{$index + 1}}.</span>
<span data-ng-bind="question.category"></span>
</small>
</div>
答案 0 :(得分:2)
更改下面的复选框值
<input type="radio" name="myquestion" data-ng-model="myquestion.category" value="Moral Ethics" >
<input type="radio" name="myquestion" data-ng-model="myquestion.category" value="Religion & Culture" >
和你重复的div如下所示
<div ng-repeat="question in questions | filter:myquestion">
<small>
<span >{{$index + 1}}.</span>
<span data-ng-bind="question.category"></span>
</small>
</div>
以及更新plunker
答案 1 :(得分:1)
在角度使用单选按钮时出现了一些错误,所以这是您需要做的一些更改。以下是您视图的更新代码。
<div class="col-md-3">
<label class="green">
<input type="radio" name="myquestion" data-ng-model="selectedCategory" value="Moral Ethics"><span>Moral Ethics</span></label>
</div>
<div class="col-md-3">
<label class="green">
<input type="radio" name="culture" data-ng-model="selectedCategory" value="Religion & Culture"><span>Religion & Culture</span></label>
</div>
<div ng-repeat="question in questions | filter:selectedCategory">
<small>
<span >{{$index + 1}}.</span>
<span data-ng-bind="question.category"></span>
</small>
</div>
答案 2 :(得分:1)
我更新你的Plunker
http://plnkr.co/edit/uN2NoO8JaBUINRkvEljt?p=preview
为此:
<div ng-controller="MyCntrl">
<div class="col-md-3">
<label class="green"><input type="radio" name="myquestion" data-ng-model="category" value="Moral Ethics" ><span>Moral Ethics</span></label></div>
<div class="col-md-3">
<label class="green"><input type="radio" name="culture" data-ng-model="category" value="Religion & Culture" ><span>Religion & Culture</span> </label></div>
<div ng-repeat="question in questions|filter:category ">
<small>
<span >{{$index + 1}}.</span>
<span data-ng-bind="question.category"></span>
</small>
</div>
</div>
它工作正常。