angularjs ng-click传参控制ng-repeat元素显示与隐藏
来源:互联网 发布:中央司法警官学院 知乎 编辑:程序博客网 时间:2024/04/29 14:00
ng-click传参控制ng-repeat元素显示与隐藏
说明:
1、使用ng-repeat显示参数
2、通过ng-click按钮显示或隐藏内容。通过添加shows和id两个参数控制显示。
<!DOCTYPE html><html><head><meta charset="utf-8"><script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script></head><body> <div ng-app="myApp" ng-controller="personCtrl" ng-init="names=[{name:'Jani',country:'Norway',shows:'true',id:0},{name:'Hege',country:'Sweden',shows:'true',id:1},{name:'Kai',country:'Denmark',shows:'true',id:2}]"> <button ng-click="toggle()">隐藏/显示</button> <div ng-repeat='item in names'> <div ng-hide="item.shows">OKOK</div> <button ng-click="showItemId(item.id)">{{item.name}}</button> </div> Javascript: <p ng-hide="myVar"> 名: <input type=text ng-model="firstName"> <br> 姓: <input type=text ng-model="lastName"> <br> <br> 姓名: {{firstName + " " + lastName}} </p> </div> <script> var app = angular.module('myApp', []); app.controller('personCtrl', function($scope) { $scope.firstName = "John", $scope.lastName = "Doe" $scope.myVar = false; $scope.showItemId = function(itemId) { $scope.names[itemId].shows = false; alert("Item Id 是 " + itemId); }; $scope.toggle = function() { $scope.myVar = !$scope.myVar; } }); </script></body></html>
0 0
- angularjs ng-click传参控制ng-repeat元素显示与隐藏
- AngularJS - 在ng-repeat中使用ng-click为元素添加class
- angularjs directive ng-repeat里ng-click 不起作用解决办法
- angularjs ng-click 传参数
- angularjs ng-click获取当前元素
- angularjs ng-repeat
- angularjs ng-repeat
- Angularjs中的ng-repeat
- angularJS ng-repeat
- angularjs ng-repeat
- angularjs-ng-repeat
- angularjs ng-repeat
- AngularJS ng-click bug
- AngularJs --ng-click事件
- AngularJS ng-repeat 中的ng-click事件以及参数的传递
- AngularJS ng-repeat下使用ng-model
- AngularJS ng-repeat下使用ng-model
- AngularJS ng-repeat下使用ng-model
- 天下无难事,天下无易事
- linux下使用python连接Mysql
- 操作系统中的时间计算
- LeetCode之3---Longest Substring Without Repeating Characters
- 实现两个有序链表的合并
- angularjs ng-click传参控制ng-repeat元素显示与隐藏
- 关于编程学习上的一些感悟——不忘初心
- LeetCode 231 Power of Two(三解)
- mysql安装到最后一步无响应的问题解决
- iOS 用UISearchController自定义搜索界面
- JavaScript 引用类型
- hdu-1247 Hat’s Words(字典树)
- 第五周上机实践项目——项目3-时间类(2)
- 创建一个集合图像