【发布时间】:2018-11-19 15:37:32
【问题描述】:
使用 angular5,我在互联网上找到了这段代码,我尝试在我的应用程序中运行它,因为我想要同样的东西,它没有按预期工作,问题是我可以检查所有单选按钮,也我甚至可以在选择任何单选按钮元素之前看到第一条消息。
<form>
Pick a topic:
<input type="radio" ng-model="myVar" value="dogs">Dogs
<input type="radio" ng-model="myVar" value="tuts">Tutorials
<input type="radio" ng-model="myVar" value="cars">Cars
</form>
<div ng-switch="myVar">
<div ng-switch-when="dogs">
<h1>Dogs</h1>
<p>Welcome to a world of dogs.</p>
</div>
<div ng-switch-when="tuts">
<h1>Tutorials</h1>
<p>Learn from examples.</p>
</div>
<div ng-switch-when="cars">
<h1>Cars</h1>
<p>Read about cars.</p>
</div>
</div>
知道为什么这对我不起作用吗?我还没有导入任何库来处理这个例子。
这是用于此示例的 link 即时通讯,但它不适用于此链接中的我。
【问题讨论】:
-
这不是 angular5 它的 angularjs 有什么问题?
-
啊,好吧,我想知道为什么它不工作,我怎么能在 angular v5 中做同样的事情?
标签: angular radio-button angular5 frontend ng-switch