0

与研究文章的披露提交 (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 而没有更新

4

2 回答 2

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>

于 2017-03-22T15:55:07.233 回答
0

如果您希望复选框默认选中,您可以更改

<input type="checkbox" checked ng-model="checkbox.articleCheckbox1"/>

到:

<input type="checkbox" ng-checked="true" ng-model="checkbox.articleCheckbox1"/>
于 2017-03-22T15:57:15.613 回答