[英]angular boolean value not changing for the save
我的控制器中有一个范围。 这是什么
$scope.carprice.active = true
现在在我看来我有两个单选按钮。 两者都是这样的。
ng-click="carprice.active=true"
ng-click="carprice.active=false"
如何使范围更改值? 目前,即使在我点击了false选项后,它仍然保存到数据库中。
我已经尝试将点击作为模型,但也没有用。
谢谢山姆
你不应该使用ngClick,你需要ngValue指令并将单选按钮绑定到同一个carprice.active
模型:
<script src="https://code.angularjs.org/1.4.8/angular.js"></script> <script>angular.module('demo', [])</script> <div ng-app="demo" ng-init="carprice.active = true;"> <input type="radio" ng-model="carprice.active" ng-value="true"> Active <input type="radio" ng-model="carprice.active" ng-value="false"> Not active <pre>{{ carprice.active }}</pre> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.