2017-04-10 52 views
0

工作,我有以下呈现的HTML:ngShow不能与多元

<div class="tutorial-dot ng-hide" ng-show-start="currentStep"> 
    <div class="dot"></div> 
</div> 
<div class="tutorial-modal" ng-show-end=""> 

正如你所看到的,NG-节目开始元素被隐藏,但NG秀尾部元件是没有的。它们应该都应用了相同的ngShow指令实例,因为它支持multiElement,但ngShow指令在ng-show-end元素上无法正常工作。

回答

0

我能够通过去除第一个div上的ng-hide类来得到这个工作。我添加了一些文字,以查看节目是否正常工作。 currentStep未初始化,因此它将开始隐藏div。当你点击按钮时,它将通过ng-click将currentStep的值翻转为true。

<div class="tutorial-dot" ng-show-start="currentStep"> 
    <div class="dot">Hello, this will show when the current step is true.</div> 
    </div> 
    <div class="tutorial-modal" ng-show-end> 
    This is the end 
    </div> 

这里是一个codepen的链接,演示了这个工作。如果有更多关于这个问题的问题,请拨打我的codepen并显示您遇到的问题。 http://codepen.io/mkl/pen/PpMvzZ?#

+0

您的代码与我的不同之处在于,ng-show-end也具有表达式作为其值。这是必需的吗?它并没有用于我使用过的其他multiElement指令。 –

+0

我用与'ng-show-end'参数相同的表达式尝试了它,但它仍然无效。如果您在示例中将ng-init从true更改为false,则只会隐藏ng-show-start,而不是ng-show-end,因此它在您的示例中也不起作用。 –

+0

我想出了这个问题。从第一个div中删除ng-hide类。我更新了答案和代码中的代码。 – Michael