How to change button label in angularjs according to requirement?

前端 未结 2 1946
轮回少年
轮回少年 2021-01-29 01:28

I want to change the label of same button in angularjs according to requirement, same button can be for update and submit.

See the following demo,

Above demo is

2条回答
  •  既然无缘
    2021-01-29 02:22

    Change your markup for button to show some scope property:

    {{btnText}} 
    

    And add some logic to your controller, that will specify text for button:

    if (newItem){
      $scope.btnText = 'Submit';
    }else{
      $scope.btnText = 'Update';
    }
    

提交回复
热议问题