将ng-repeat变量值用于嵌套的ng-repeat时出现问题 [英] Problem in using ng-repeat variable value to the nested ng-repeat

查看:99
本文介绍了将ng-repeat变量值用于嵌套的ng-repeat时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是AngularJS的新手。在我的代码中,我有两个嵌套的ng-repeat属性,我想使用第一个ng-repeat变量值来创建下一个ng-repeat变量。这是我的代码,不是我需要的。





 <   div     ng-repeat   =  artType中的项目 >  
< 选择 ng-model = ddlArtType >
< option value = 已禁用 已选择 > < / option >
< 选项 ng-repeat = artCultureDependencyMap中的selectedArtType。{{item}}跟踪$ index >
{{selectedArtType}}
< / option >
< / select >
< / div >







这里artType是一个数组,示例值

artType = ['电影','音乐',...]

artCultureDependencyMap是一个对象。示例值

artCultureDependencyMap ['Film'] = ['Action','Adventure',....]

artCultureDependencyMap ['Music'] = ['xxx' ,'yyy',....]



我该怎么办?非常感谢您的任何帮助。

Sazzad

解决方案

index > ;
{{selectedArtType}}
< / option >
< / select >
< / div >







这里artType是一个数组,示例值

artType = ['电影','音乐',...]

artCultureDependencyMap是一个对象。示例值

artCultureDependencyMap ['Film'] = ['Action','Adventure',....]

artCultureDependencyMap ['Music'] = ['xxx' ,'yyy',....]



我该怎么办。你有什么帮助非常感谢。

Sazzad


我认为你正在努力使用嵌套的ng-repeat。希望以下代码能为您提供帮助。



 <  !DOCTYPE     html  >  
< html >
< script src = http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js\"> < / script >
< body >

< div ng-app = myApp ng-controller = myCtrl >

< div ng-repeat = artType中的项目 < span class =code-keyword>>
< select ng-model = ddlArtType >
< 选项 value = 已停用 已选择 > < span class =code-keyword>< / option >
< 选项 ng-repeat = artCultureDependencyMap [item]中的selectedArtType跟踪

index >
{{selectedArtType}}
< / option >
< / select >
< / div >

< / div >

< script >
var app = angular.module(' myApp',[]);
app.controller(' myCtrl'功能

I am new in AngularJS. In my code I have two nested ng-repeat attribute and I want to use first ng-repeat variable value to create the next ng-repeat variable. Here is my Code that not as I need.


<div ng-repeat="item in artType">    
	<select ng-model="ddlArtType">
		<option value="" disabled selected> </option>
		<option ng-repeat="selectedArtType in artCultureDependencyMap.{{item}} track by $index">
			{{selectedArtType}}
		</option>
	</select>    
</div>




Here "artType" is an array, Example value
artType=['Film', 'Music',...]
And "artCultureDependencyMap" is an object. Example value
artCultureDependencyMap['Film']=['Action','Adventure',....]
artCultureDependencyMap['Music']=['xxx','yyy',....]

What should I do here. Your any help will greatly appreciated.
Sazzad

解决方案

index"> {{selectedArtType}} </option> </select> </div>




Here "artType" is an array, Example value
artType=['Film', 'Music',...]
And "artCultureDependencyMap" is an object. Example value
artCultureDependencyMap['Film']=['Action','Adventure',....]
artCultureDependencyMap['Music']=['xxx','yyy',....]

What should I do here. Your any help will greatly appreciated.
Sazzad


I assumed that you are struggling with nested ng-repeat. Hope the following code will help you.

<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>

<div ng-app="myApp" ng-controller="myCtrl">

	<div ng-repeat="item in artType">    
	<select ng-model="ddlArtType">
		<option value="" disabled selected> </option>
		<option ng-repeat="selectedArtType in artCultureDependencyMap[item] track by


index"> {{selectedArtType}} </option> </select> </div> </div> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function(


这篇关于将ng-repeat变量值用于嵌套的ng-repeat时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆