In my project I am using angular js. I have a form and I am filling the form details using rest api. The form will get filled by object. I want to disable textbox which value was empty, so I used the following code.

<input id="Level2" ng-disabled="!EditMenu.Level2" ng-model="EditMenu.Level2" type="text" class="form-control" />

Its working fine. Its disabled when values are empty, but here my problem when users try to edit the values, they clear all the value to enter new value but user cannot be update any field since its got disabled when user clear all the value from the text box. Please help me on this.

  • How does the user clear all the values to be able to enter new ones? Is there a button for clearing? Or how do you set your "EditMenu.Level2" property? – Celophysis Jul 2 '18 at 5:56
  • this is just simple textbox so they use backspace button to clear all values – Naveen Kaliyaperumaal Jul 3 '18 at 8:33
  • I am setting inititally EditMenu={} and fill values from rest api EditMenu = results; here results is a object from rest api. – Naveen Kaliyaperumaal Jul 3 '18 at 8:33
  • reset by backspace button? I'm not really sure whether this is correct design. The form context might change and so the control might be reenabled. But the properties you set on the control used for the next request are staying or not - depends on cache or browser settings. It would be more of a proper design if you handle your reset within the current form view by adding a control changing the ng-disabled preferences. – Celophysis Jul 3 '18 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.