0

I have a text box and two radio button controls with yes or no value. If I click on Yes, the text box should be enable and it should be disabled on No selection. I have used ng-disabled property.

But, if user selects No, saves the file and reopens it, the text box is getting enabled again. Is there a way to save the text box state?

I have tried using disabled="" on textbox. but if user selects yes, enters some value and saves the files, the textbox is getting disabled again. if user selects Yes, the textbox should not be disabled till he selects No

I am talking about index.html file.

Below is my chunk of code:

<input type="radio" name="something" value="1" ng-model="checkboxSelection"/>Checkbox 1
<input type="radio" name="something" value="2" ng-model="checkboxSelection"/> Checkbox 2
<input type="text" ng-model="somevalue" name="somevalue" ng-disabled="checkboxSelection=='2'"/>
2
  • Which file are you talking about? Commented Jul 31, 2015 at 13:25
  • Please show your code Commented Jul 31, 2015 at 13:25

2 Answers 2

1

try this

<input type="checkbox" ng-click="disable = !disable">
<input type="text" ng-disabled='disable'/>

If you want to clear the value of the input after check no, use a function in you're controller

Sign up to request clarification or add additional context in comments.

Comments

0
<input type="radio" ng-model="disable_input" ng-value="true" />
<input type="radio" ng-model="disable_input" ng-value="false" />
<input type="text" ng-disabled="disable_input" />

I'm not sure if you want to use and input or textarea as your "textbox" but all you would need to do to make it a textarea instead is use the ng-disabled in the last input element in a textarea instead.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.