问题标签 [angularjs-ng-switch]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
4 回答
6437 浏览

javascript - angularjs:从 ng-switch 中的控制器更改父范围

所以,我可以从子控制器更改模型值,但是当子控制器在时,ng-switch它就不起作用,为什么?我创建了一个示例来演示它。

避免这种情况的一种方法是.在模型名称中使用 ,例如bunnies.kills. 这是一个错误还是一个功能?

使用 Angular 1.0.6

0 投票
1 回答
265 浏览

angularjs - 如何使用 ng-switch (angularjs) 添加许多字段

我有两个嵌套的 ng-repeat,我想多次添加相同的表单MiseEnContext,在这个“MiseEncontext”中我想添加一些输入,但是当我添加文本时,它会添加到我所有的MiseEnContext 问题:如何隔离我的MiseEncontext ?

演示:http ://plnkr.co/edit/Cr0WN4hCuKTYJOfb5CBf?p=preview

0 投票
1 回答
1692 浏览

angularjs - 数据模型更改时 ngSwitch 不更新

我是 Angular 的新手,正在尝试编写一些简单的应用程序。我在使用 ngSwitch 按需切换相应指令时遇到问题,如下所示。

html标记:

主 html 文件:directiveOne:

以及在控制器之间共享数据的服务。

最后是指令的 3 个控制器。

然后我尝试更改 ShareDataFct var,但视图(ng-switch)不会更改以根据 myvar 更改显示指令。请指教。谢谢你。

0 投票
1 回答
127 浏览

angularjs - 如何将 $last ngRepeat 结果从href中取出?

是否有任何选项可以像这样放置 $last ng-repeat 结果<li class="active">Four</li>而不是<li><a href="#">Four</a></li>?我一直在尝试,ng-if但不幸的是它还没有给出好的解决方案:(

演示:http ://codepen.io/anon/pen/bdvVRe

0 投票
2 回答
2330 浏览

angularjs - ng-switch-when 和 ng-class 兼容性

我想知道当 ng-switch-when 和 ng-class 在与此示例中相同的元素上使用时是否没有兼容性问题。

我正在尝试动态更改这四个元素的类,但由于某些原因,这不适用于所有元素,仅适用于当前显示的元素。

有谁知道这里发生了什么?

在 div 之间切换。

返回一门课或另一门课。

非常感谢。

0 投票
2 回答
588 浏览

javascript - 如何使用 ng-switch-when 获取非空 json?

我是 angularjs 的新手,并且我的 angularjs 应用程序中有 json,我希望 ng-switch 在该 json 不为空(它是一个数组)时工作。这是一个很大的 json,我说的是其中的一部分,ng-switch 有可能吗?或者我应该在我的控制器中设置范围参数?或其他一些我不知道的方式

JSON

标记

0 投票
0 回答
51 浏览

angularjs - ngTransclude in ngSwitch

I have a popover, and this popover has ngTransclude. We show/set popup with ngSwitch (true/false). The issue here is that ngTransclude is inside ngSwitch and this slows down the application, because every time we show a popover we have to transclude/$compile. Is there a way to fix this issue?

Now we cannot just move transclude outside of popup, because that means, if I have a ng-repeat inside transcluded element, this ng-repeat is watched then, but we dont want that, we want to watch for this ng-repeat when popup is opened.

0 投票
2 回答
216 浏览

angularjs - ng-switch 放置元素

有没有更好的方法来写这个?我只是不想重复列表的内部内容两次。

0 投票
1 回答
434 浏览

angularjs - 角度和离子 - ng-switch 更改 url

我正在开发一个有角度的应用程序,我正在尝试使用 ng-switch 设置一个中继器。

到目前为止,我的代码如下所示:

ng-switch 工作正常,因为我可以看到正确的文本,我现在遇到的问题是我需要将 url 更改为如下所示:

这是我坚持的一点,因为我真的不知道是否可以用 ng-if 以这种方式做某事。

我知道最简单的方法是将href移动到ng-switch-when中,但问题是如果我移动它,离子框架打印的列表将不再正确呈现......

如何以正确的方式使用 angular 根据 id 更改链接?

谢谢

0 投票
3 回答
859 浏览

javascript - 如何在 ng-repeat 中使用 ng-switch 来编辑 JSON API 数据

我知道这是一个反复出现的问题,但不幸的是,我找不到合适的答案来解决我的问题。

基本上,我从 JSON API 端点获取数据,该端点使用ng-repeat. 我现在想要ng-switch查看输入字段以修改数据(并稍后将其发送回服务器)。

Atm,我的解决方案取决于在数据中拥有我不喜欢的属性。我确信有比在检索数据后注入此属性更聪明的方法 - 有什么建议吗?

HTML:

JS:

提前致谢!

这是一个 plunker: http ://plnkr.co/edit/h8ar4S43JUvjHurzLgT0?p=preview