我正在尝试查看用户是否已订阅计划,如果是,请检查相应的单选按钮。md-radio-button无法识别ng-checked
我有一组我要创建与NG-重复MD单选按钮:
<md-radio-group class="md-primary" ng-model="plan">
<div flex ng-repeat="planInfo in plans" class="plan-options">
<md-radio-button value="{{planInfo._id}}" name="plan" class="md-primary" ng-checked="hasPlanID == planInfo._id" required>
<h2 class="plan-name">{{planInfo.name}}</h2>
<h3 class="plan-price">${{planInfo.price}}</h3>
</md-radio-button>
</div>
</md-radio-group>
我有一个是越来越所有的从数据库中计划服务:
//check to see if user already has a plan
MyService.GetPlan(currentUser.username).then(function (response) {
if (response.success) {
//This does resolve correctly
$scope.hasPlanID = response.data.plan;
MyService.GetAllPlans().then(function (response) {
if (response.success) {
//plans display properly
$scope.plans = response.data;
} else {
$log.debug(response.message);
}
});
} else {
$log.debug(response.message);
}
});
注意HTML中的ng-checked属性。当我查看Chrome的检查器时,它会精确地吐出你在代码中看到的内容,ng-checked =“hasPlanID == planInfo._id”。
如何让它识别变量值并将实际表达式解析为true或false?
我的回答看起来好像很无聊,谢谢! – sigmapi13
没问题,我很高兴它解决了! – JimmyBoh