访问单选按钮导致jQuery

时间:2015-10-05 02:17:37

标签: jquery angularjs

我想在jQuery中访问所选的单选按钮值,我是否能够在jQuery中访问ng-model值?

HTML code:

<p>Selected Value: <span class="radioValue">{{ data.group1 }}</span> </p>
<md-radio-group ng-model="data.group1">
   <md-radio-button class="rad" name="radio" value="Enable" id="enable" class="md-primary">Enable</md-radio-button>
 <md-radio-button class="rad" name="radio" value="Disable" id="disable">Disable</md-radio-button>
</md-radio-group>

   <button id="device" type="submit" class="button buttonBlue">

jQuery的:

$('#device').click(function() {
    var makeModel = $('#data.group1').val();
    alert("make=" + makeModel);
});

请建议。

1 个答案:

答案 0 :(得分:0)

您可以使用以下代码

获取'md-radio-group'元素的范围
var data = $('#radioGroup1').scope().data;
var makeModel = null;
if(data) makeModel = data.group1;
alert("make=" + makeModel);

鉴于您已更新html模板以包含广播组的ID

<md-radio-group id='radioGroup1' ng-model="data.group1">