2014-09-02 41 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