这个问题的本质是:v-repeat会产生子scope,这时你在控制器里拿值,相当于父scope里面取子scope的值,因为Angular.js中作用域是向上查找的,所以取不到。

操作过程如下:

  

相关代码如下:

<table>
<tr>
<th>序号</th><th>姓名</th><th>工资</th><th>操作</th>
</tr>
<tr>
<td>{{$index+1}}</td>
<td>{{item.name}}</td>
<td><input name="salary" ng-model="salary" /></td>
<td><button ng-click="myAlert()">弹出工资</button></td>
</tr>
</table>
<script>
QryListCtrl.$inject = ['$scope', '$remote'];
function QryListCtrl($scope, $remote){
$scope.myAlert = function(){
alert($scope.salary);
}
}
</script>

解决方法:

<table>
<tr>
<th>序号</th><th>姓名</th><th>工资</th><th>操作</th>
</tr>
<tr>
<td>{{$index+1}}</td>
<td>{{item.name}}</td>
<td><input name="salary" ng-model="$parent.salary" /></td>
<td><button ng-click="myAlert()">弹出工资</button></td>
</tr>
</table>

原理:把子scope中的值通过 $parent属性传递给父scope即可。

最新文章

  1. 关于js中this关键字的补充
  2. php开发必备小工具
  3. 献给所有从事IT行业拥有梦想的英语渣们
  4. JS判断一个数组中是否有重复值的三种方法
  5. Android eclipse中程序调试
  6. C语言面试题(嵌入式开发方向,附答案及点评)
  7. IEnumerable&lt;T&gt;转换为IList&lt;SelectListItem&gt;
  8. iOS UIActivityIndicatorView 的使用
  9. 孤儿文档是怎样产生的(MongoDB orphaned document)
  10. git log 中文乱码问题(浪费了一天)
  11. java基础-静态,非静态(构造)代码块,类加载
  12. angularjs知识点
  13. ----XMLHttpRequestAPI简单介绍----
  14. Java 多线程 interrupt方法
  15. 雷林鹏分享:XML 验证
  16. js中return ,return true,return false;区别
  17. php设置头部让任何域名请求
  18. Python2.7-copy
  19. linux诡异的硬盘不足
  20. java编程内容之开始

热门文章

  1. JavaWeb-spring
  2. AS配置IDE
  3. Python多重装饰器
  4. cherrypy应用探究
  5. quick-cocos2d-x :加入精灵背景
  6. 161228、Java IO流读写文件的几个注意点
  7. 常用快捷键(WebStorm, Eclipse, Sublime)
  8. Dell DRAC的重启方法
  9. Linux:-防火墙iptables如何个性化定制?
  10. C# 获取指定目录下所有文件信息、移动目录、拷贝目录