ng disable未更新

时间:2016-03-15 10:55:46

标签: javascript angularjs

我有三个表单,有三个不同的名称,并有一个按钮,这应该根据当前的表单验证禁用 -

<ng-form="form0">
    //some required fields
    </ng-form>

    <ng-form="form1">
    //some required fields
    </ng-form>

    <ng-form="form2">
    //some required fields
    </ng-form>

<button class="btn btn-primary" ng-click="goToNextTab()" ng-disabled="{{'form'+currentIndex}}.$invalid" ng-show="currentIndex>=0&&currentIndex<3">Next</button>

但是最初这个按钮被禁用并且在填写form1后启用了它,但是当我转到下一个表单时,按钮已经启用而没有填写表单

$scope.goToNextTab=function()
    {
        $scope.currentIndex++;
    };

3 个答案:

答案 0 :(得分:1)

ng-disabled是一个布尔变量,只能指定为true或false,并为其指定字符串

答案 1 :(得分:1)

观看3个表单并按如下方式设置按钮状态:

select
  partyid,
  min(case when first_is_one = 1 then credit end) as opening,
  sum(case when total > credit then price else 0 end) as debit,
  sum(case when total < credit then price else 0 end) as credit, 
  min(case when last_is_one = 1 then total end) as closing
from
(
  select
    po.partyid, po.credit, po.total, po.price,
    row_number() over (partition by po.partyid order by po.date) as first_is_one,
    row_number() over (partition by po.partyid order by po.date desc) as last_is_one
  from tblpartyorder po
  where po.date >= '2014-03-06' and po.date <= '2016-03-09'
) marked
group by partyid
order by partyid;

FIDDLE

答案 2 :(得分:0)

ng-disabled="'form'+currentIndex.$invalid"

无需{{..}}