与研究文章的披露提交(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}}部分的复选框,我的结果也只显示为false,但未获得更新
答案 0 :(得分:0)
看起来你的代码即使在1.6+下工作,我删除了检查属性,如果你提供了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>
答案 1 :(得分:0)
如果您希望默认选中该复选框,则可以更改
<input type="checkbox" checked ng-model="checkbox.articleCheckbox1"/>
要:
<input type="checkbox" ng-checked="true" ng-model="checkbox.articleCheckbox1"/>