【问题标题】:Getting issue at the time of receving check box value : Angularjs收到复选框值时出现问题:Angularjs
【发布时间】:2018-01-31 17:23:22
【问题描述】:

我正在尝试获取复选框的值,但我选中了复选框,将值设置为 true 和 false,但我不想要这个。

<div class="checkbox checkbox-warning">
     <input type="checkbox" ng-model="search.industries" ng-init="search.industries = i.name" value="{{i.name}}" class="styled" id="industry-{{i.id}}" data-taggable="1" data-tag-id="i-agriculture-fisheries-plantation">
                            {{search.industries | json}}
     <label for="industry-{{i.id}}">{{i.name}}</label>
</div>

我只想得到我在 {{i.name}} 中得到的值。我已经通过使用这些代码行进行了尝试,但仍然将值设为 true n false。

请帮我搞定这个。 提前致谢。

【问题讨论】:

  • I'm trying to get the value of value of check box - 你想在哪里得到它?你的代码在哪里?
  • 一个复选框实际上是用于提供真值或假值。你想做什么?
  • 我正在尝试获取 json。当我点击复选框时,在 json 中它显示为真,当我取消选中它时,它显示为假。

标签: angularjs


【解决方案1】:

试试这个

value="{{search.industries = i.name}}"

如果上面的方法不起作用,那么试试下面的代码

<div class="checkbox checkbox-warning">
     <input type="checkbox" ng-model="search.industries" ng-init="search.industries = i.name" value="{{i.name}}" class="styled" id="industry-{{i.id}}" ng-change="stateChanged(i.name)" data-taggable="1" data-tag-id="i-agriculture-fisheries-plantation">
                            {{search.industries | json}}
     <label for="industry-{{i.id}}">{{i.name}}</label>
</div>


//js
$scope.stateChanged = function (name) {
       $scope.search.industries=name;
       alert(name);
}

【讨论】:

  • 此行不适用于 me.cz 使用我无法点击复选框。
  • @dev_02 i'm unable to clicked on checkbox 那你为什么要使用复选框?你可以带标签吗?
猜你喜欢
  • 1970-01-01
  • 2018-04-19
  • 1970-01-01
  • 2021-02-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-01-10
相关资源
最近更新 更多