Text box value is undefined


#1

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


#2

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


#4

I update your coding with this:

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

ng-model=“person.contactPersonName”;

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