Text box value is undefined

I getting value of text box using ng-model but in angular js it is undefined
for example;

  <input type="text" ng-model="contactPersonName" placeholder="Contact Person Name">
  <button ng-click="click(contactPersonName)">OK</button>

alert("Contact Person Name : " + name);

O/P:::: Contact Person Name : undefined

Try to do like this enclose your variable inside an object
like this in your controller


in your view do like this


also in ng-click function parameter

1 Like

I update your coding with this:

‘contactPersonName’ : ‘’


and got success…btw thank you so much :relaxed::relaxed::relaxed:

1 Like