0

I have a use case where I submit a form which in turn does a $http.get(). The get url accepts paramter say: &code ='P' &code='C'. Where P and C are to be selected from checkbox and passed to this parameter "code".

I am using angular material checkbox, but everytime I submit the form "code" parameter is getting set to true instead of P or C.

  $scope.putCall = {};
  $scope.putCall.p = 'P';
  $scope.putCall.c = 'C';

  <md-checkbox ng-model="putCall.p" aria-label="P" name="P_put_call_code">
   P: {{ putCall.p }}
  </md-checkbox>
  <md-checkbox ng-model="putCall.c" aria-label="C">
   C: {{ putCall.c }}
   </md-checkbox>

How do I pass "P" instead of true.

1 Answer 1

1

As in documentation:

ng-true-value The value to which the expression should be set when selected.

So in your case that would look like:

<md-checkbox ng-model="putCall.p" ng-true-value="P" ng-false-value="" aria-label="P" name="P_put_call_code">
   P: {{ putCall.p }}
</md-checkbox>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.