【发布时间】:2016-04-21 15:44:52
【问题描述】:
我没有完全了解 ng-switch。这就是我想要做的: 我的身体有一个可以根据我单击的按钮进行更改的类。
<body class="green">
....
<button onclick="document.body.className='green'">green</button>
<button onclick="document.body.className='blue'">blue</button>
我的想法是我需要通过 ng-include 包含一个文本,我希望它是
<div ng-include="green.html"></div> //if body has class green
<div ng-include="blue.html"></div> //if body has class blue
我知道我可以用 ng-switch 做到这一点,但我不知道怎么做。
你能帮帮我吗?
【问题讨论】:
-
法比奥,非 è chiaro cosa vuoi ottenere,spiegati meglio... :-)
-
你可以做
ng-include="color == 'green' ? 'green.html': 'blue.html'" -
你试过使用它吗?您说您对
ng-switch感到困惑,但您的代码甚至没有显示ng-switch或您的任何尝试。展示一个不起作用或语法错误的尝试比仅仅说你不理解并期望有人为你写一个解决方案要好....