Angular用ng-repeat生成表单并绑定ng-click时的一个细节
2016-03-10 19:34
615 查看
偶然发现一个问题是ng-repeat里面生成的DOM并绑定ng-click的时候,时间cardshow写法是正确可运行的,但是一旦写成cardShow就会报错,这点试错了很久才发现,记下来防止后人踩坑,看到的就留意一下这个地方,避免困扰了,貌似驼峰写法是不支持的,不知道是否姿势不对哈哈~
$scope.cardshow = function(e){
console.log(e);
console.log("测试一下");
}
$scope.cardShow = function(e){
console.log(e);
console.log("测试一下");
}
<table class="table table-striped" style="font-weight:normal;">
<tr value='{{cardShows}}' class="{{cardShows.length==0&&cardShows?'ng-hide':'ng-show'}}">
<th style="font-weight:normal;">名字</th>
<th style="font-weight:normal;">价格</th>
<th style="font-weight:normal;">操作</th>
</tr>
<tr ng-repeat="cardShow in cardShows">
<!--<th>{{cardShow.card_id}}</th>-->
<td style="font-weight:normal;">{{cardShow.card_name}}</td>
<td style="font-weight:normal;">¥{{cardShow.price}}</td>
<td style="font-weight:normal;"><div style="margin: 0; padding: 0;" class="btn btn-primary" type="button" value="删除" ng-click="cardshow(cardShow)">删除</div></td>
</tr>
</table>
</div>
$scope.cardshow = function(e){
console.log(e);
console.log("测试一下");
}
$scope.cardShow = function(e){
console.log(e);
console.log("测试一下");
}
<table class="table table-striped" style="font-weight:normal;">
<tr value='{{cardShows}}' class="{{cardShows.length==0&&cardShows?'ng-hide':'ng-show'}}">
<th style="font-weight:normal;">名字</th>
<th style="font-weight:normal;">价格</th>
<th style="font-weight:normal;">操作</th>
</tr>
<tr ng-repeat="cardShow in cardShows">
<!--<th>{{cardShow.card_id}}</th>-->
<td style="font-weight:normal;">{{cardShow.card_name}}</td>
<td style="font-weight:normal;">¥{{cardShow.price}}</td>
<td style="font-weight:normal;"><div style="margin: 0; padding: 0;" class="btn btn-primary" type="button" value="删除" ng-click="cardshow(cardShow)">删除</div></td>
</tr>
</table>
</div>
相关文章推荐
- JQuery1——基础($对象,选择器,对象转换)
- Android学习笔记(二九):嵌入浏览器
- Android java 与 javascript互访(相互调用)的方法例子
- JavaScript演示排序算法
- javascript实现10进制转为N进制数
- easyui------显示隐藏列功能
- html5 web数据存储
- 最后一次说说闭包
- Ajax
- SEO
- 2019年开发人员应该学习的8个JavaScript框架
- HTML中的script标签研究
- 对一个分号引发的错误研究
- 异步流程控制:7 行代码学会 co 模块
- [译] React 入门
- ES6 走马观花(ECMAScript2015 新特性)