2016-02-18 137 views
1

我有一组单选按钮,当我加载我的应用程序时,第一个广播是默认选中的,所以如果我去第二个广播我可以在HTML表格中看到不同的信息,那么If我更改了过滤器的值,然后发出请求,我希望单选按钮再次刷新,并且已选择默认值但不会发生,第二个单选按钮将被选中。双单选按钮选择bug AngularJs

<div class="radio" ng-init="topTable='topCategory'"> 
     <label class="radio-inline"><input type="radio" ng-model="topTable" value="topCategory" ng-change="updateTotals('topCategory')">TY Top 30 Categories</label> 
     <label class="radio-inline"><input type="radio" ng-model="topTable" value="topSupplier" ng-change="updateTotals('topSupplier')">TY Top 10 Suppliers</label> 
     <label class="radio-inline"><input type="radio" ng-model="topTable" value="topBrand" ng-change="updateTotals('topBrand')">TY Top 10 Brands</label> 
    </div> 

了NG-INIT使第一无线电将被选择我也使用的功能的这样

function topRadios() { 
     $scope.topTable = "topCategory"; 

    } 

和我的NG-INIT是 “NG-INIT =” topRadios()“;

我不知道如果我需要使用,而不是价值或NG-值,如果我需要一些逻辑添加到我的控制器或者是什么。

任何帮助?

+1

你试图做这样的事情? http://jsfiddle.net/u9vm0ryx/2/ – BuddhistBeast

+0

@BuddhistBeast你应该提交它作为答案 – eltonkamami

+0

谢谢,它的作品! @BuddhistBeast 你可以把它作为答案,所以我可以把它标记为正确的。 – kennechu

回答

0

你可以只记得像这样的功能:

<button ng-click="triggerTable()" type="button">Refresh</button> 

而且相应的功能:

$scope.triggerTable = function() { 
    $scope.topTable = "topCategory"; 
} 

Example