我尝试了与巫师形式的jQuery passthrough,它效果很好。现在,但是我有一个问题。当formwizard中的步骤在指令内(所有步骤显示而不是仅显示您的第一个步骤)时,jQuery Passhrough似乎无效:
):<form ui-jq="formwizard" ui-options="{formPluginEnabled: false, validationEnabled: false, focusFirstInput : false, disableUIStyles : true}" ng-submit="create(currentActivity, selectedCategories)" class="main">
<!--STEP 1 -->
<div activity-wizard-step title="Class Activity Info" description="Add all info about the activity" src="resources/angular/templates/activity_wizard/activity_info.html" step-number="1"></div>
<!-- STEP 2 -->
<div activity-wizard-step title="Add Class(es)" description="dd Instructor-Led-Training (ILT) Classes below. It can be a classroom ILT or a Webinar ILT and contain 1 or more sessions." src="resources/angular/templates/activity_wizard/add_class.html" step-number="2"></div>
</form>
这是我的ActivityWizardStep指令的样子:
directivesModule.directive('activityWizardStep', function () {
return {
replace: true,
restrict: 'AE',
scope: {
title: '@',
description: '@',
src: '@',
stepNumber: '@'
},
templateUrl: 'resources/angular/templates/activity_wizard/wizard_step.html'
}
});
和wizard_step.html:
<fieldset class="step" id="step{{stepNumber}}">
Some html
</fieldset>
就像我之前说过的,所有步骤始终显示。我认为这是某种计时问题,例如指令或当jQuery PassThrough试图初始化FormWizard时,指令或Include并不完全在DOM中。这是发生了什么吗?如果是这样,我应该使用$超时吗?如果是这样,我会把它放在哪里。也许有更好的方法。有任何想法吗?
答案是,不要使用angularjs的formwizard :)。在查看了进一步的ng-switch之后,不仅可以做到这一点,而且简化了很多东西。
<form ng-switch="navStep" class="main">
<!--STEP 1 -->
<div ng-switch-when="activity_info" activity-wizard-step title="Class Activity Info" description="Add all info about the activity" src="resources/angular/templates/activity_wizard/activity_info.html" step-number="1"></div>
<!-- STEP 2 -->
<div ng-switch-when="add_class" activity-wizard-step title="Add Class(es)" description="dd Instructor-Led-Training (ILT) Classes below. It can be a classroom ILT or a Webinar ILT and contain 1 or more sessions." src="resources/angular/templates/activity_wizard/add_class.html" step-number="2"></div>
</form>
然后在单击下一个和背面按钮时在集合中。
基本上,Angular的令人敬畏使Formwizard不必要。