我想在来自 Angular Controller 的 html 表中显示数据,我有 Controller ,但我想在选择其中一个单选按钮时显示该数据,但我不知道如何实现这一点。
<div class="radio">
<label class="radio-inline"><input type="radio" name="top30Categories">TY Top 30 Categories</label>
<label class="radio-inline"><input type="radio" name="top10Brands">TY Top 10 Brands</label>
<label class="radio-inline"><input type="radio" name="top10Suppliers">TY Top 10 Suppliers</label>
</div>
我的表格位于“div”标签内,我在其中使用其他数据调用另一个 Controller ,当我加载页面时默认显示此数据
<div class="panel panel-default" ng-controller="HttpGetTestController">
因此,当我选择其中一个单选按钮时,我需要在该 html 表中显示不同的数据。
最佳答案
我不确定,但我认为这就是你想要的。
Here is a plunker ,每次您单击单选按钮时,它都会调用一个事件。
HTML:
<input type="radio" ng-click="radioButton(1)">
<input type="radio" ng-click="radioButton(2)">
<input type="radio" ng-click="radioButton(3)">
AngularJS:
$scope.radioButton = function(arg){
alert(arg);
//Place your code here
}
关于javascript - 从单选按钮读取 Angular Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34593249/