0

I have used ng-blur and pass data using a function and I couldnot print the value by using console.log in the controller

test.template.html

<div class="col-value">
    <input type="text" autofocus="autofocus" style=' box-sizing: border-box; width:50%' ng-blur="saveData()" ng-model="value">%
</div>

test.controller.js

$scope.saveData = function(){

  console.log($scope.value);

  };

Can someone kindly help me to solve this issue? Thanks inadvance

0

2 Answers 2

1

Try This, pass the ng-model value inside ng-blur="saveData(value)" function.

<div class="col-value">
    <input type="text" autofocus="autofocus" style=' box-sizing: border-box; width:50%' ng-blur="saveData(value)" ng-model="value">%
</div>

$scope.saveData = function(value){

  console.log(value);

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

Comments

0

Your code is working fine. Compare the below code snippet with your code.

var app = angular.module('app', []);

app.controller('MainCtrl', function($scope) {
  
  $scope.saveData = function(){

  console.log($scope.value);

  };
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script>
<body  ng-app="app" ng-controller="MainCtrl">
   <div class="col-value">
    <input type="text" autofocus="autofocus" style=' box-sizing: border-box; width:50%' ng-blur="saveData()" ng-model="value">%
</div>
  </body>

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.