angularjs - How do I bind the same data to different options using angulajs? -


i'm trying select data , bind specific item, once select data, of items bound selected data. how can select specific data each of items.

here demo. http://play.ionic.io/app/cb25b106e671

you need mapping data structure save selection each day. there can better way quite can this

  $scope.data = {      "monday": {workout: ''},      "tuesday": {workout: ''},      "wednesday": {workout: ''},      "thursday": {workout: ''},      "friday": {workout: ''},      "saturday": {workout: ''},      "sunday": {workout: ''}   } 

and need track current day selected can map selected workout currentday key.

so first, set curretday when open workout selector doing this

    <a class="item" ng-repeat="day in days" ng-click="openmodal(day.day)">{{data[day.day].workout}}         <span class="item-note">{{day.day}}</span>     </a> 

and

$scope.openmodal = function(day) {   $scope.currentday = day;   $scope.modal.show(); }; 

second, when workout selected need set on currentday key

<ion-radio class="item" ng-repeat="item in workouts" ng-value="item.workout" ng-model="data[currentday].workout">{{item.workout}}</ion-radio> 

here complete working demo (based on demo of course)


Comments