0

I have a text box and two buttons on a page. The textbox recieves data from the database. If the textbox has a value I want to show Turn Off and hide the other. If the textbox doesn't have a value I want show Turn On and hide the other.

Because I am binding the textbox to sessionStorage.clientId, null gets displayed in the textbox if there is no data for the corresponding field in database. And also always Turn On button only showsup. what am i doing wrong.

Here is the Plunker

1
  • I guess, null is treated as string("null") instead of null value. Your plunker works fine but does not reflect your question. Please update your plunker. Commented May 13, 2016 at 17:25

2 Answers 2

1

In your controller, you should stick with that

  $scope.ssclientID = {
     code: 'CS123BD'
   }

and use $scope.ssclientID.code in ng-model and everything should work just fine

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

Comments

1

It works

Everything works fine, there is nothing wrong with your code. Plunker fails to load Angular, other than that it's OK. Here is the copy/paste to codepen.io : http://codepen.io/ssh33/pen/jqRmdb?editors=1010

I added checks for an empty string '' for giggles, but everything else is yours.

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.