HVD
HVD

Reputation: 251

Convert ng-model Angular to Javascript - jQuery

I have a model of the question, answer id. question.answer7[20] && question.answer7[25].

How to convert this ng-model back to HTML and Javascript (or jQuery).

<md-checkbox ng-model="question.answer7[20]" ng-true-value="'69'">CheckboxA</md-checkbox>
<md-checkbox ng-model="question.answer7[25]" ng-true-value="'24'">CheckboxB</md-checkbox>

I have tried to put the input name answer7[20] and answer7[25]. And try console $('input[name="answer7"]'), but seem like jQuery not understand and return null;

<input name="answer7[20]" type="checkbox" checked value="69">CheckboxA
<input name="answer7[25]" type="checkbox" checked value="24">CheckboxB

console.log($('input[name="answer7"]')); // return null

Sorry for my poor English.

Upvotes: 0

Views: 54

Answers (1)

Pritesh
Pritesh

Reputation: 337

Try this:

console.log($('input[name^="answer7"]'));

Upvotes: 2

Related Questions