kennechu
kennechu

Reputation: 1422

Read angular controller from radio button

I want to display data in an html table comming from an Angular controller, I have the controller but I want to display that data when I select one of the radio buttons but I don't know how to achive this.

  <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>

I have my table inside a "div" tag where I call another controller with other data, this data is displayed by default when I load the page

<div class="panel panel-default" ng-controller="HttpGetTestController">

So what I need is to display different data in that html table when I select one of the radio buttons.

Upvotes: 1

Views: 273

Answers (1)

RiesvGeffen
RiesvGeffen

Reputation: 1589

I'm not sure, but I think this is what you want.

Here is a plunker, every time you click on a radiobutton it calls an event.

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
}

Upvotes: 1

Related Questions