2014-09-02 43 views
0

我正在开发一个表单,如果此向导按钮为true,那么会出现一个“向导按钮”,表单呈现为向导。Angularjs条件向导

有避免代码重复的简单方法吗?

为例:

<wizard on-finish="saveit()" ng-if="data.form.config.wizardmode"> 
<wz-step title="Starting" ng-if="$index==0 && data.form.config.wizardmode"> 
    <h1>This is the first step</h1> 
    <p>Here you can use whatever you want. You can use other directives, binding, etc.</p> 
    <input type="submit" wz-next value="Continue" /> 
</wz-step> 
<wz-step title="Continuing"> 
    <h1>Continuing</h1> 
    <p>You have continued here!</p> 
    <input type="submit" wz-next value="Go on" /> 
</wz-step> 
<wz-step title="More steps"> 
    <p>Even more steps!!</p> 
    <input type="submit" wz-next value="Finish now" /> 
</wz-step> 
</wizard> 

如果向导的时候,我将不得不重新编写整个形式? 有没有一个很好的逻辑(角度的方式)基本上隐藏/显示所有<wz-step>标签?

谢谢,Patrick

+0

你可以为每个表格做一个指令 – 2014-09-02 16:53:49

+0

但我还有两种形式? – 2014-09-02 17:54:46

+0

你将有2个表格,但你只会写一次 – 2014-09-02 17:56:47

回答

0

请检查这是不是您要找的。我做了一个plunkr。

Plunkr

基本上我写的向导指令,这就是所谓的WizardStep子指令。

<wizard showWizard="showWizard"> 
    <wizard-step step-number=1> 
    Step 1 
    </wizard-step> 
    <wizard-step step-number=2> 
    Step 2 
    </wizard-step> 
    <wizard-step step-number=3> 
    Step 3 
    </wizard-step> 
</wizard> 
+0

如果我使用ng-在'wizard'标签上显示所有内容都是隐藏的,所以我必须重写表单,或者你的意思是? – 2014-09-02 17:54:25