angularjs - Combine checkbox and radio's with multiple angular models -


i'm building configurator tool people can configure own kitchen , need logics here.

let's people can select sink: when checkbox checked, list appears multiple sinks (radio buttons). default, when checkbox checked, first radio button should checked well.

i want several things happen here:

1) when checkbox checked, radio buttons should appear. first radio button should checked default , value of json object should stored in formdata.sink.

2) price of selected sink should saved in prices[x].price.

3) when checkbox unchecked, value of prices[x].price should set 0 , formdata.sink object should empty.

here's html. in controller don't have functions yet.

<tr class="tr-border-top">   <td colspan="2"><input type="checkbox" ng-model="sink">sink</td>   <td>{{ prices[5].price  | currency:"€":0}},-</td> </tr> <tr ng-show="sink">   <td colspan="3">      <ul>         <li ng-repeat="node in nodes | filter:{type:'sink'}">            <label>               <input type="radio" name="sink" class="form-control" ng-model="formdata.sink" ng-value="node" ng-init="$index==0?(formdata.sink=node):''">               {{ node.title}}            </label>         </li>      </ul>    </td>  </tr> 

well, seems didn't try yourself. go adding ng-change , call function sets values want them

<input type="checkbox" ng-model="sink" data-ng-change="onsinkchanged(sink)">  $scope.onsinkchanged = function(sink) {     // logic here } 

and in function can set correct values , if unchecked, reset values 0 or undefined. try of , if stuck specify exact problem :)


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -