javascript - 从单选按钮读取 Angular Controller

标签 javascript angularjs

我想在来自 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/

相关文章:

javascript - 如何使用 JavaScript 创建 SVG 动画标签

ios - 使用 Angular.js 和 iOS 客户端对 Node.js 应用程序进行身份验证

javascript - AngularJS $http.post(...).success 不是具有文件上传方法的函数

javascript - 获取 URL 的最后一个字符

javascript - Tablesorter 无法处理表

javascript - nodejs 向子进程发送信号不起作用

javascript - Angular JS 中的 Lodash - 获取 TypeError : Object function lodash(value)

javascript - AngularJS 中的语法错误 : Token 'a1' is unexpected, 期待 [)]

javascript - 如何在 AngularJS 中排序时删除重复值?

javascript - 将 knockout 模板绑定(bind)到自定义组件后如何更改 View 模型的数据