2016-02-18 138 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