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>

$scope.click=function(name){
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

$scope.person={};

in your view do like this

 ng-model="person.contactPersonName";

also in ng-click function parameter

1 Like

I update your coding with this:

$scope.person={
‘contactPersonName’ : ‘’
};

ng-model=“person.contactPersonName”;

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

1 Like