Reputation: 115
As a new "Angularian", I have this:
<div data-ng-app="" data-ng-init="">
<input type="text" ng-model="hello">
<p>{{hello}}</p>
</div>
But I wonder, how can I console.log whatever I type in the expression (ng-model)?
(e.g. if I type "Soylent Green is people" in the text field I want to see it in Chrome's Inspector window)
Upvotes: 0
Views: 2875
Reputation: 11
Use ng-change directive with your input tag like
<input type="text" ng-model="hello" ng-change="textChange()" >
and in your controller
$scope.textChange = function () {
console.log($scope.hello);
}
https://jsfiddle.net/walioulislam/wpjwavrc/
Upvotes: 1
Reputation: 23
You have a controller for this app, if you don't know about controllers you can read the documentation in w3schools
You can do console.log($scope.hello)
inside your controller
By default each and every variable you define in HTML is inside $scope object
Upvotes: 0
Reputation: 91
You can use console.log($scope.hello);
inside your controller.
I suggest you to take a look about Addons/Extensions like Batarang and ng-inspector. This is the newest one, and as the name suggests, it allows you to inspect your application's scopes.
Upvotes: 1