Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS - passing this.value into a function

I have this code in native javascript and it works all right. it logs the textbox's current value

<script>
    var boom = function(val) {
        console.log(val);
    };
</script>

<input type="text" onclick="boom(this.value)"/>

Then I want to do the same on AngularJS without using model. Here is the code:

$scope.boom = function(val) {
    console.log(val);
};

<input type="text" ng-click="boom(this.value)"/>

But it always logs undefined!
Why?

like image 926
boi_echos Avatar asked Oct 20 '14 10:10

boi_echos


Video Answer


1 Answers

As I know, this in context of ng-* is a scope.
You may access via boom($event.target.value).

like image 101
Miraage Avatar answered Oct 10 '22 05:10

Miraage