Madhumita Chowdhury
Madhumita Chowdhury

Reputation: 169

angular material checkbox

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.

Upvotes: 0

Views: 923

Answers (1)

stack item
stack item

Reputation: 564

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>

Upvotes: 1

Related Questions