angularjs - Angular - work with ng-model and radio buttons to toggle value in array -


i have array starts default product ids added id.

i have list of other products set default needs toggled using radio button.

the code have following:

app = angular.module('myapp', []) app.controller('myctrl', [   '$scope',   ($scope) ->       $scope.list = [10]       $scope.full = [         {id: 10, name: "test 1"}         {id: 11, name: "test 2"}       ]        $scope.itemisinlist = (id) ->         console.log id         console.log $scope.list.indexof(id)         return $scope.list.indexof(id) > -1  ])    <div ng-app="myapp" ng-controller=myctrl>     {{list}}     <ul class="list-group">         <li class="list-group-item  justify-content-between"             ng-repeat="l in full">             <span class="pull-left">{{l.name}}</span>             <div class="toggle-switch">                 <label class="switch">                     <input type="radio" name="radio" ng-model="list" ng-checked="itemisinlist(l.id)">                     <span class="slider round"></span>                 </label>             </div>             <div class="clearfix"></div>         </li>     </ul> </div> 

and here's pen use: https://codepen.io/nickhg/pen/dzpbxe

how can toggle value present in array , replace (replace, not add) new value of radio button?

thanks suggestion


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -