- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我遇到以下情况,我正在构建一个测验,我有一些问题,有些问题有子问题,具体取决于您的回答,我希望显示与答案相对应的问题。
例如:
Question title:
- Answer 1
- Another question with answers 1
- Answer 2
- Another question with answers 2
因此,当您按“答案 1”时,您将看到“另一个带有答案 1 的问题”,或者如果您按“答案 2”,您将看到“另一个带有答案 2 的问题”
我的应用程序结构如下所示:
$scope.currentIndex = 0;
$scope.questions = [{
title: 'Question title',
choices: ['Answer 1', 'Answer 2'],
extra: {
childs: [{
link: 'answer-1',
title: 'Another question with answers 1',
choices: ['Some answer', 'Some answer 2']
}, {
link: 'answer-2',
title: 'Another question with answers 2',
choices: ['Some answer', 'Some answer 2']
}]
}
}, {
title: 'Simple question title',
choices: ['Answer 1', 'Answer 2']
}]
在我的 Angular 应用程序中,我使用以下方式显示问题:
ng-repeat="question in questions track by $index" ng-if="isCurrentQuestion($index)"
isCurrentQuestion()
函数如下所示:
$scope.isCurrentQuestion = function(index) {
return $scope.currentQuestion === index
};
每次回答问题时,我都会向 $scope.currentIndex 添加 +1 以显示下一个问题。
我不明白的是如何在我的应用程序中显示来自 (question.extra.childs
) 的子问题?
也许我的结构不太正确,但我愿意接受想法。
最佳答案
使用嵌套的 ng-repeat 方法来解决您的需求。
<div ng-repeat="question in questions">
// Do your logic here
// use ng-if for your condition, if its true it will show your child elements
<div ng-if="question.condition" ng-repeat="extraquestions in question.extra.childs">
// Do your logic here
</div>
</div>
关于javascript - AngularJS 跟进子逻辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32630455/
ASP.NET 团队和社区在 .NET 8 继续全力投入 Blazor,为它带来了非常多的新特性,特别是在服务端渲染(SSR)方面,一定程度解决之前 WASM 加载慢,Server 性能不理想等局限
我正在尝试执行一个小程序,但无法真正完全理解它。在某些地方,我认为它的作用是错误的,但我知道 where =[] 如果有人能指出我正确的方向,我将不胜感激。 import java.util.*; p
感谢您对我上一篇文章的帮助,@AndyE,您的解决方案效果很好。 现在我的后续行动,相同的想法,不同的功能...我尝试实现您之前的解决方案,但无法让它正常工作...: $(document).keyp
我有一个看起来像这样的列表: ('string ', 'time', 'SPY', 0, 0, 131.63, 100), ('sting ', 'time', 'SPY', 0, 0, 131.63
多年来,我们一直在使用 BoundsChecker for Visual C++ 6(我认为它也是 BoundsChecker 5 或 6)。我们已经升级到 VS2008(终于!),现在需要跟进过时的
这是这个问题的后续:Why does a division result differ based on the cast type? 快速总结: byte b1 = (byte)(64 / 0.8f
再次免责声明:我是 Clojure 新手。感谢您的帮助。 我之前的问题 ( Clojure's defrecord - how to use it? ) 产生了一个有效的数据结构和方法:https:/
这是 MySQL count / track streaks or consecutive dates 的后续问题 马特为我之前的问题提供的解决方案效果很好,但现在我遇到了一个问题,因为我正在处理 1
关于问题Multiple delegates per one object?其中一个答案提出了有趣的解决方案(至少对于我天真的眼睛来说):创建一个“委托(delegate)拆分器”,允许一个对象(在本
首先,请阅读我认为我修复了它的旧帖子。 (没时间可以跳过) Firefox interacts with my timers somehow ?!?! This is crazy ^^ 对于那些不想阅
您好,提前谢谢您。这是来自以下线程的跟进问题(不确定我是否应该在那里发布或开始一个新线程......: CSRF token missing or incorrect even though I ha
我之前问过一个问题,根据用户点击这篇文章的哪个链接来填充页面,可以在这里找到: How to populate 1 php page differently depending on link cli
跟进 https://stackoverflow.com/a/3448189 ,实际显示密码屏幕的最佳方式是什么? 我的第一次尝试是使用 LockActivity 启动 SubActivity: //
这是对 How to interpret ggplot2::stat_density2d 的直接跟进. bins已作为参数重新添加 see this thread和 corresponding git
这是 Why is my OpenMP implementation slower than a single threaded implementation? 的后续内容. 我坚持提供的答案,并使用
跟进我之前的问题。 谁能解释为什么下面的代码编译没有任何错误: typedef array MethodArray; typedef array ParameterArray; ParameterAr
按照@AlexWein 在this question 中的建议看着 ProGuard Troubleshooting ,我在 SherlockFragment 中有以下内容: Class c = Cl
这是我之前问过的一个关于计算直手的问题的后续问题......不完全一样......这是读牌的方法 - 它有效 - 但有没有更好的方法 - 做这在 C 中使用控制台输入 ... void read_ca
这是 Previous Question 的跟进 它变得非常复杂,所以我开始一个新线程来使我的观点更清楚。(不想删除以前的线程,因为其他提供有值(value)反馈的人不会失去他们获得的声望点数) 更新
这是对 my previous question 的跟进. 假设我使用以下原型(prototype)编写了一个函数: int a_function(Foo val); 其中 foo 被认为是一个类型定
我是一名优秀的程序员,十分优秀!