use*_*480 7 javascript wizard angularjs fuelux
我正在使用fuelUX向导和Angularjs.我希望根据此控制器方法启用或禁用下一个按钮:
$scope.canMoveForward = function(){
switch($("#moduleWizard").wizard("selectedItem").step){
case 1:
//check if the module on the first step is valid*/
return $scope.validSelection && $scope.linkedPredicateForm.$valid;
case 2:
//check if the table is empty
return !linkingDataSource.isEmpty();
case 3:
var enab= ($scope.saveModeForm.$valid && $scope.newSourceForm.$valid) ||
($scope.saveModeForm.$valid && $scope.appendSourceForm.$valid)
}
};
Run Code Online (Sandbox Code Playgroud)
确实这就是我如何删除按钮:
<div class="actions">
<button class="btn btn-mini btn-prev" ng-click="refresh()"> <i class="icon-arrow-left"></i>Prev</button>
<button class="btn btn-mini btn-next" data-last="Finish" id="wizard-next" ng-disabled="!canMoveForward()"
ng-click="handleStepResult()">
Next<i class="icon-arrow-right"></i></button>
</div>
Run Code Online (Sandbox Code Playgroud)
它工作正常,除非我从第二页返回到第一页:如果第二页中的下一个按钮被禁用,即使在第一页也是如此,除非我不在那里编辑表单.无论如何刷新ng-disabled绑定?
lau*_*ent 13
我猜AngularJS无法检查输出canMoveForward()
是否发生了变化.我发现对于这类事情,依赖范围变量更容易.你可以这样做:
ng-disabled="!canMoveForward"
Run Code Online (Sandbox Code Playgroud)
然后在您的控制器中根据需要将属性设置为true/false:
$scope.canMoveForward = false;
Run Code Online (Sandbox Code Playgroud)