复选框范围具有约束力,但即使在 angular.js 1.6.x 中带有点也不会更新
checkbox scope is binding but not updating even with dot in angular.js 1.6.x
与研究文章的披露提交 (app/views/research/disclosure.html.erb) 相关的代码位于此处。
var researchDisclosureApp = angular.module('researchDisclosureApp', []);
researchDisclosureApp.controller('submissionController', ['$scope', function($scope){
$scope.checkbox = {
articleCheckbox1 : false
};
}]);
我的html代码
<div class="container dashboard-container" ng-app="researchDisclosureApp" ng-controller="submissionController">
<div class="nra-heading-area">
<div class="row">
<div class="col-sm-6">
<div class="nra-heading">New Research Article</div>
</div>
<div class="col-sm-6">
<a href="/research_guidelines" class="nra-guidelines">Guidelines for Writing Research</a>
<div class="clearfix"></div>
</div>
</div>
</div>
<div class="disclosure-right">
Your article is ready to publish. Please complete the required disclosures below to complete the submission.
</div>
<form id="disclosureContianer" name="disclosuresForm">
<div class="ArticleStep2MainBox">
<p class="ArticleStep2MainText">1. Please Confirm:</p>
<div class="ArticleStep2Text01">
<div class="ChoiceButtonBoxWA">
<input type="checkbox" checked id="articleCheckbox1" ng-model="checkbox.articleCheckbox1"/>
</div>
I have prepared this research note in accordance with Code of Conduct.
{{checkbox.articleCheckbox1}}
</div>
即使我取消选中或选中前端 {{checkbox.articleCheckbox1}} 部分的复选框,我的结果也只显示错误而没有得到更新
看起来你的代码即使在 1.6+ 上也能正常工作,我删除了 checked 属性,如果你提供了 ng-model 它会为你完成工作。
var researchDisclosureApp = angular.module('researchDisclosureApp', []);
researchDisclosureApp.controller('submissionController', ['$scope', function($scope) {
$scope.checkbox = {
articleCheckbox1: false
};
}]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.2/angular.js"></script>
<div class="container dashboard-container" ng-app="researchDisclosureApp" ng-controller="submissionController">
<div class="nra-heading-area">
<div class="row">
<div class="col-sm-6">
<div class="nra-heading">New Research Article</div>
</div>
<div class="col-sm-6">
<a href="/research_guidelines" class="nra-guidelines">Guidelines for Writing Research</a>
<div class="clearfix"></div>
</div>
</div>
</div>
<div class="disclosure-right">
Your article is ready to publish. Please complete the required disclosures below to complete the submission.
</div>
<form id="disclosureContianer" name="disclosuresForm">
<div class="ArticleStep2MainBox">
<p class="ArticleStep2MainText">1. Please Confirm:</p>
<div class="ArticleStep2Text01">
<div class="ChoiceButtonBoxWA">
<input type="checkbox" id="articleCheckbox1" ng-model="checkbox.articleCheckbox1" />
</div>
I have prepared this research note in accordance with Code of Conduct. {{checkbox.articleCheckbox1}}
</div>
</div>
</form>
</div>
如果您希望复选框默认选中,您可以更改
<input type="checkbox" checked ng-model="checkbox.articleCheckbox1"/>
收件人:
<input type="checkbox" ng-checked="true" ng-model="checkbox.articleCheckbox1"/>
与研究文章的披露提交 (app/views/research/disclosure.html.erb) 相关的代码位于此处。
var researchDisclosureApp = angular.module('researchDisclosureApp', []);
researchDisclosureApp.controller('submissionController', ['$scope', function($scope){
$scope.checkbox = {
articleCheckbox1 : false
};
}]);
我的html代码
<div class="container dashboard-container" ng-app="researchDisclosureApp" ng-controller="submissionController">
<div class="nra-heading-area">
<div class="row">
<div class="col-sm-6">
<div class="nra-heading">New Research Article</div>
</div>
<div class="col-sm-6">
<a href="/research_guidelines" class="nra-guidelines">Guidelines for Writing Research</a>
<div class="clearfix"></div>
</div>
</div>
</div>
<div class="disclosure-right">
Your article is ready to publish. Please complete the required disclosures below to complete the submission.
</div>
<form id="disclosureContianer" name="disclosuresForm">
<div class="ArticleStep2MainBox">
<p class="ArticleStep2MainText">1. Please Confirm:</p>
<div class="ArticleStep2Text01">
<div class="ChoiceButtonBoxWA">
<input type="checkbox" checked id="articleCheckbox1" ng-model="checkbox.articleCheckbox1"/>
</div>
I have prepared this research note in accordance with Code of Conduct.
{{checkbox.articleCheckbox1}}
</div>
即使我取消选中或选中前端 {{checkbox.articleCheckbox1}} 部分的复选框,我的结果也只显示错误而没有得到更新
看起来你的代码即使在 1.6+ 上也能正常工作,我删除了 checked 属性,如果你提供了 ng-model 它会为你完成工作。
var researchDisclosureApp = angular.module('researchDisclosureApp', []);
researchDisclosureApp.controller('submissionController', ['$scope', function($scope) {
$scope.checkbox = {
articleCheckbox1: false
};
}]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.2/angular.js"></script>
<div class="container dashboard-container" ng-app="researchDisclosureApp" ng-controller="submissionController">
<div class="nra-heading-area">
<div class="row">
<div class="col-sm-6">
<div class="nra-heading">New Research Article</div>
</div>
<div class="col-sm-6">
<a href="/research_guidelines" class="nra-guidelines">Guidelines for Writing Research</a>
<div class="clearfix"></div>
</div>
</div>
</div>
<div class="disclosure-right">
Your article is ready to publish. Please complete the required disclosures below to complete the submission.
</div>
<form id="disclosureContianer" name="disclosuresForm">
<div class="ArticleStep2MainBox">
<p class="ArticleStep2MainText">1. Please Confirm:</p>
<div class="ArticleStep2Text01">
<div class="ChoiceButtonBoxWA">
<input type="checkbox" id="articleCheckbox1" ng-model="checkbox.articleCheckbox1" />
</div>
I have prepared this research note in accordance with Code of Conduct. {{checkbox.articleCheckbox1}}
</div>
</div>
</form>
</div>
如果您希望复选框默认选中,您可以更改
<input type="checkbox" checked ng-model="checkbox.articleCheckbox1"/>
收件人:
<input type="checkbox" ng-checked="true" ng-model="checkbox.articleCheckbox1"/>