Javascript 不稳定单选按钮,带iCheck的角度
我有一个单选按钮Javascript 不稳定单选按钮,带iCheck的角度,javascript,html,css,angularjs,Javascript,Html,Css,Angularjs,我有一个单选按钮 <ul class="data-list-2" style="margin-left: 15px;"> <li> <input name="rate" type="radio" class="required" value="Stucture" ng-model="contact.package"> <label>Structuring and Drafting Plan</label
<ul class="data-list-2" style="margin-left: 15px;">
<li>
<input name="rate" type="radio" class="required" value="Stucture" ng-model="contact.package">
<label>Structuring and Drafting Plan</label>
</li>
<li>
<input name="rate" type="radio" class="required" value="Implement" ng-model="contact.package">
<label>Implementing and Managing Plan</label>
</li>
<li>
<input name="rate" type="radio" class="required" value="both" ng-model="contact.package">
<label>Both</label>
</li>
</ul>
组织和起草计划
-
实施和管理计划
-
二者都
问题是,当我单击单选按钮时,它会被选中,但不会出现在范围变量上。
当我检查元件时,我看到以下情况:
<li>
<div class="iradio_square-aero">
<input name="rate" type="radio" class="required ng-pristine ng-untouched ng-valid" value="both" ng-model="contact.package" style="position: absolute; opacity: 0;">
<ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; border: 0px; opacity: 0; background: rgb(255, 255, 255);"></ins></div>
<label>Both</label></li>
两者
另外,我发现页面正在使用
<!-- Radio and checkbox styles -->
<script src="check_radio/jquery.icheck.js"></script>
请指导如何将无线电值传递给angular。如果它没有进入作用域,则将其置于任何位置检查一次
{contact.package}
(或)将{{$scope.contact.package}
如果它没有进入作用域,则将其置于任何位置检查一次{{contact.package}
(或)将{$scope.contact.package}}
您的单选按钮值将在您在输入元素上为ng model=“”指定的任何范围属性上可用。试着这样做:
Your radio button's value will be available on whatever scope property you've assigned ng-model="" to on the input element. Try something like this:
JS
app.controller('MyCtrl', function($scope){
$scope.submitForm = function (){
alert($scope.radioValue):
};
$scope.radioValue = 1;
});
HTML
<form name="myForm" ng-controller="MyCtrl" ng-submit="submitForm()">
<label><input type="radio" name="test" ng-model="radioValue" value="1"/> One</label>
<label><input type="radio" name="test" ng-model="radioValue" value="2"/> Two</label>
<label><input type="radio" name="test" ng-model="radioValue" value="3"/> Three</label>
<div>currently selected: {{radioValue}}</div>
<button type="submit">Submit</button>
</form>
JS
app.controller('MyCtrl',函数($scope){
$scope.submitForm=函数(){
警报($scope.radioValue):
};
$scope.radioValue=1;
});
HTML
一个
两个
三
当前选定:{{radioValue}}
提交
查看此链接:您的单选按钮值将在您在输入元素上为ng model=“”指定的任何范围属性上可用。试着这样做:
JS
app.controller('MyCtrl',函数($scope){
$scope.submitForm=函数(){
警报($scope.radioValue):
};
$scope.radioValue=1;
});
HTML
一个
两个
三
当前选定:{{radioValue}}
提交
查看此链接:除了原始HTML之外,您还使用什么将原始标记转换为包含
等内容的内容?是jQuery插件吗?这可能是导致您出现问题的原因,因此请在问题中包括问题的详细信息。此外,要获得人们对标签的期望行为(单击它会检查相应的单选按钮),您应该设置标签的for
属性,以匹配无线电输入的(唯一)id
;或者你可以把
放在
开始和结束标记中(在标签文本之前)。@GregL:我已经用jquery更新了这个问题lib@GregL:我检查了这个,但它也不工作。任何建议请参阅,以获取有关如何生成angular指令的提示,从而使iCheck能够很好地处理angular。然后将i-check
属性添加到您的
中,并删除默认的iCheck功能,该功能会自动将其添加到所有单选按钮中。除了原始HTML之外,您在使用什么将原始标记转换为包含
等内容?是jQuery插件吗?这可能是导致您出现问题的原因,因此请在问题中包括问题的详细信息。此外,要获得人们对标签的期望行为(单击它会检查相应的单选按钮),您应该设置标签的for
属性,以匹配无线电输入的(唯一)id
;或者你可以把
放在
开始和结束标记中(在标签文本之前)。@GregL:我已经用jquery更新了这个问题lib@GregL:我检查了这个,但它也不工作。任何建议请参阅,以获取有关如何生成angular指令的提示,从而使iCheck能够很好地处理angular。然后将i-check
属性添加到您的
中,并删除自动将其添加到所有单选按钮的默认iCheck功能。{{$scope.contact.package}
将不起作用,因为当前作用域本身没有作为名为$scope
的属性填充。{{double curly方括号}}之间的表达式在该点根据当前作用域求值。可以将其视为将当前作用域视为该表达式的全局作用域。{{{$scope.contact.package}
将不起作用,因为当前作用域本身没有作为名为$scope
的属性填充。{{double curly方括号}}之间的表达式在该点根据当前作用域求值。可以将其视为将当前范围视为该表达式的全局范围。