ng-ng repeat 遍历map可不可以分多次遍历

ng-repeat遍历后如何在不同控制器之间将遍历结果进行传值 - 开源中国社区
当前访客身份:游客 [
当前位置:
&!doctype html&
&html ng-app&
&&& &meta charset="utf-8"&
&&& &title&ng-repeat directive&/title&
&table ng-controller="CartController"&
&&& &caption&我的购物车&/caption&
&&&&&&& &th&序号&/th&
&&&&&&& &th&商品&/th&
&&&&&&& &th&操作&/th&
&&& &tr ng-repeat="item in items"&
&&&&&&& &td&{{$index + 1}}&/td&
&&&&&&& &td id="gs"&{{item.name}}&/td&&
&&&&&&& &td&
&&&&&&&&&&& &button ng-click="show(item.name)"&show&/button&
&&&&&&& &/td&
&script src="../lib/angularjs/1.2.26/angular.min.js"&&/script&
&&& function CartController($scope) {
&&&&&&& $scope.items = [
&&&&&&&&&&& {name: "苹果"},
&&&&&&&&&&& {name: "香蕉"}
&&&&& {name: "李子"},
&&&&&&& ];
&&&&&& $scope.show=function(name){
&&&& //我想根据传进来的name值是苹果还是香蕉或其他,能显示出不同的信息,我原来想用document.getElementById("gs ").innerHTML来获取每条记录的name值,但是结果是每次都获取的是第一条苹果的值。请教各位如何才能获取对应的name值,并且可以把这个值传到另外一个控制器下。谢谢
&/html&tcsId
共有0个答案
更多开发者职位上
有什么技术问题吗?我要留言技术领域:
你已经自动关注本知识库了哦!
确定要取消收藏吗?angular ng-repeat 如何实现这样的嵌套 a是数据 但是每隔4个我得包一个li_问答_ThinkSAAS
angular ng-repeat 如何实现这样的嵌套 a是数据 但是每隔4个我得包一个li
angular ng-repeat 如何实现这样的嵌套 a是数据 但是每隔4个我得包一个li
&a href="#"class="a-lists"&&/a&
&a href="#"class="a-lists"&&/a&
&a href="#"class="a-lists"&&/a&
&a href="#"class="a-lists"&&/a&
&a href="#"class="a-lists"&&/a&
&a href="#"class="a-lists"&&/a&
&a href="#"class="a-lists"&&/a&
&a href="#"class="a-lists"&&/a&
&a href="#"class="a-lists"&&/a&
&a href="#"class="a-lists"&&/a&
&a href="#"class="a-lists"&&/a&
&a href="#"class="a-lists"&&/a&
&a href="#"class="a-lists"&&/a&
&a href="#"class="a-lists"&&/a&
&a href="#"class="a-lists"&&/a&
&a href="#"class="a-lists"&&/a&
你这个相当是两个遍历咯。
比如结构是
some:[{name:11},{name:222},{},...]
&li ng-repeat="subrow in row"&
&a ng-repeat='sec in subrow.some' class='a-lists'&{{sec.name}}&/td&
添加你想要问的问题
PHP开发框架
开发工具/编程工具
服务器环境
ThinkSAAS商业授权:
ThinkSAAS为用户提供有偿个性定制开发服务
ThinkSAAS将为商业授权用户提供二次开发指导和技术支持
让ThinkSAAS更好,把建议拿来。
开发客服微信Angular ng-repeat 对象和数组遍历实例
字体:[ ] 类型:转载 时间:
这篇文章主要介绍了Angular ng-repeat对象和数组遍历的相关资料,并附代码示例,需要的朋友可以参考下
直接上代码
&!DOCTYPE html&
&meta name="description" content="[Ngrepeat in obj and arr]"&
&script src="/ajax/libs/angular.js/1.3.14/angular.min.js"&&/script&
&meta charset="utf-8"&
&title&JS Bin&/title&
&div ng-app="myApp"&
&div ng-controller="testCtrl"&{{test1}}
&label for="" ng-repeat="item in list1"&{{item.id}} -- {{item.value}}&/label&
&label for="" ng-repeat="(key, value) in obj1"&{{key}} -- {{value}}&/label&
对于obj遍历的话 会根据key的首字母排序
&label for="" ng-repeat="(key, value) in obj2"&
{{key}} -- {{value.text}} -- {{value.value}}
var app = angular.module(‘myApp‘, []);
app.controller(‘testCtrl‘, function ($scope) {
$scope.test1 = ‘tt‘;
$scope.list1 = [{
id: ‘1‘,
value: ‘seti‘
id: ‘2‘,
value: ‘kuma‘
id: ‘3‘,
value: ‘cent‘
$scope.obj1 = {
‘1‘: ‘seti‘,
‘2‘: ‘kuma‘,
‘3‘: ‘cent‘
$scope.obj2 = {
‘ins‘:{text:‘seti‘, value:‘s1‘},
‘abc‘:{text:‘kuma‘, value:‘s2‘},
‘coln‘:{text:‘cent‘, value:‘s3‘}
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具

我要回帖

更多关于 ng repeat 遍历map 的文章

 

随机推荐