我试图从离子控制器绑定单选按钮的值。以下是我用过的代码。
<div class="list">
<ion-radio ng-model="SearchChoice" ng-value="All" ng-click="SearchByFilter('All')"> ALL <div id="badge-all" class="count-jkt"> <span ng-bind="AllCount.OnGoing"></span></div></ion-radio>
<ion-radio ng-model="SearchChoice" ng-value="New" ng-click="SearchByFilter('New')"> NEW <div id="badge-new" class="count-jkt">{{AllCount.New}}</div></ion-radio>
</div>
我的控制器是,
.controller('MainCtrl', function($scope) {
$scope.SearchChoice = "All";
$scope.SearchByFilter = function(item) {
console.log( "Filter:", item);
};
});
这里的值没有正确绑定。请帮助我们!
答案 0 :(得分:0)
您可以使用.
表示法尝试吗?
<div class="list">
<ion-radio ng-model="model.SearchChoice" ng-value="All" ng-click="SearchByFilter('All')"> ALL <div id="badge-all" class="count-jkt"> <span ng-bind="AllCount.OnGoing"></span></div></ion-radio>
<ion-radio ng-model="model.SearchChoice" ng-value="New" ng-click="SearchByFilter('New')"> NEW <div id="badge-new" class="count-jkt">{{AllCount.New}}</div></ion-radio>
</div>
.controller('MainCtrl', function($scope) {
$scope.model = {
SearchChoice: "All"
};
$scope.SearchByFilter = function(item) {
console.log( "Filter:", item);
};
});
有关.
表示法的详细信息,请参阅here。