angularjs - 无法在 Angular 的 ng-bind 中将数据传递到控制器
问题描述
我使用了 ng-blur 并使用函数传递数据,但无法在控制器中使用 console.log 打印值
test.template.html
<div class="col-value">
<input type="text" autofocus="autofocus" style=' box-sizing: border-box; width:50%' ng-blur="saveData()" ng-model="value">%
</div>
test.controller.js
$scope.saveData = function(){
console.log($scope.value);
};
有人可以帮我解决这个问题吗?提前致谢
解决方案
试试这个,在 ng-blur="saveData(value)" 函数中传递 ng-model 值。
<div class="col-value">
<input type="text" autofocus="autofocus" style=' box-sizing: border-box; width:50%' ng-blur="saveData(value)" ng-model="value">%
</div>
$scope.saveData = function(value){
console.log(value);
};
推荐阅读
- c++ - Linux Mount 使用 Remount 以允许读写
- javascript - 可以将数据从烧瓶发送到Javascript吗?
- python - 在python中,我想计算一个尚不存在的数字要减去多少,并且只有在我知道要起飞的数量后才会存在
- java - singleshoicedialog 中正负按钮的问题
- python - 使用 argparse 打开 json 文件?
- typescript - 使用打字稿转换我想查找并替换 this 关键字,我该如何找到它?
- python - int 对象在 python 中不可下标
- angular - patchValue with { emitEvent: false, onlySelf: true } 触发 Angular 中的 valueChanges
- flutter - 如何更改导航抽屉的工具栏颜色
- sql - 要搜索的数千个值