2

Disable Form On the basis of Dynamic Id of form using Angularjs? like Id of form come from Foreach Loop..

<div class="pan" style="margin-top:40px">
                            <div ng-repeat="e in  Data">
                                <hr>
                                <p class="text-muted" style="color:darkgreen">Q. {{e.Question}}</p>
                                <form  id="{{e.QuizQuestionID}}">

                                        <div ng-repeat="s in e.option" id="e.QuizQuestionID">

                                            <label>
                                                <input name="options"
                                                       type="radio"
                                                       ng-click="check(e.QuizQuestionID,s.QqID)">
                                            </label>

                                            <span>{{s.ops}}  </span>


                                        </div>

                                </form>
                            </div>

                        </div>`
  • Have a look on this. [https://stackoverflow.com/questions/21638079/angularjs-disabling-all-form-controls-between-submit-and-server-response](https://stackoverflow.com/questions/21638079/angularjs-disabling-all-form-controls-between-submit-and-server-response) – Akbar Khan Feb 06 '19 at 09:00

2 Answers2

1

did you have a chance to have a look on this link!

try adding ng-disabled="expression" in the properties as described .

M.Elfeky
  • 81
  • 12
0

You can use ng-disabled directive that angularjs provides for this purpose. For example HTML:

<form  id="{{e.QuizQuestionID}}">
  <div ng-repeat="s in e.option" id="e.QuizQuestionID">

  <label>
      //ng-disabled used here
      <input name="options"
             type="radio"
             ng-disabled="quizIsDisabled(e.QuizQuestionID)" 
             ng-click="check(e.QuizQuestionID,s.QqID)">
  </label>

  <span>{{s.ops}}  </span>


  </div>
</form>

In your controller:

$scope.quizIsDisabled = function(id){
  //do you logic here, for example
  return ["we32a","ewd23","4dscs"].indexOf(id) != 0
}
phuwin
  • 3,130
  • 4
  • 26
  • 49