0

I have this radio button in my ionic app:

<ion-radio ng-model="data.sort" ng-value="['-timestamp','model']" ng-click="closeSortPopover();">Recent model (default)</ion-radio>

but it doesn't check itself when I set $scope.data.sort to ['-timestamp','model'] somewhere else in the controller or view.

See the codePen here.

2
  • you mean doesnt check itself??? Commented Nov 28, 2015 at 14:27
  • oh yes ! sorry, I edited Commented Nov 28, 2015 at 15:26

1 Answer 1

1

if i wrap your array to a scope variable it works just fine

html

<ion-nav-view>
     <ion-view>
       <ion-content>

          <ion-radio ng-model="data.sort" ng-value="someValue" ng-click="closeSortPopover();">['-timestamp','model']</ion-radio>
          <ion-radio ng-model="data.sort" ng-value="'brand'"   ng-click="closeSortPopover()">Brand</ion-radio>

         <br/><br/>

         <button id="resetbutton" class="button icon-left ion-ios-reload button-dark" ng-click='data.sort=someValue;'>Set to data.sort to ['-timestamp','model']</button>

         <br/><br/>

         data.sort = {{data.sort}}
       </ion-content>
     </ion-view>  
</ion-nav-view>

controller

angular.module('ionicApp', ['ionic'])

.controller('MyCtrl', function($scope) {
  $scope.myTitle = 'This header hides the content below';
  $scope.someValue = ["-timestamp","model"];
  $scope.data={};
  $scope.data.sort = $scope.someValue;
});
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @Mat. perfect !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.