Vishal Mahuli Vishal Mahuli - 1 year ago 60
AngularJS Question

How to pass value from a textbox to a function in AngularJs?


<input type ="text" ng-model="contactid" >

I want to pass the contactId value entered in this box to a function
which is called
of submit button after the box.

How do I do this?

Answer Source

You can do it like so:

<form ng-controller="formCtrl">     
    <input type="text" name="name" ng-model="inputValue" />
    <button ng-click="abc(inputValue)"></button>

Or using ng-submit directive:

<form ng-controller="formCtrl" ng-submit="abc(inputValue)">     
    <input type="text" name="name" ng-model="inputValue" />
    <button type="submit"></button>

And in your formCtrl controller:

.controller('formCtrl', function () {
    $scope.inputValue = null;
    $ = function (value) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download