Angularjs multiple radio button, auto-select if only one is present -


Many intolerant radio buttons have been successful in creating an angular application.

But to select the default one is a radio button if only one exists.

Tried to exclude the stuff, but it does not work for many radio buttons.

Code explanation:

HTML code: I have two radio buttons, the second set of radio buttons is generated on the basis of the first.

  & lt; Div & gt; & Lt; Ul & gt; & Lt; Li & gt; Part One: & lt; / Li & gt; & Lt; Li ng-repeat = "f in input" & gt; & Lt; Input type = "radio" name = "single input" ng-value = "f" ng-model = "$ parent.one" & gt; & Amp; Nbsp; {{F.Name}} & amp; Nbsp; & Lt; / Input & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt; Br / & gt; & Lt; Div & gt; & Lt; Ul & gt; & Lt; Li & gt; Part two: & lt; / Li & gt; & Lt; Li ng-repeat = "Filtered user in U = (One.User | filter: {valid: 'y'})" & gt; Input  

If I select a radio button in the first set, and the second set has only one radio button, then it should be chosen by default. For example, if I select D, I get the D2 radio button which should be selected.

Full Code @

Appreciate your feedback.

please see here:

  $ scope $ Watch ('one', function (value) {if (value.Name) {var user = $ filter ('filter') ($ scope.Input, value); var vaildUsers = $ filter ('filter') (user [0]. User, {Valid: "Y"}); if (vaildUsers.length == 1) {$ scope.Two = vaildUsers [0];} and {$ scope.Two = {}}}}} ;  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -