Yahorow
Yahorow

Reputation: 51

How to get value inside ng-change?

I have the following input field:

 '<input check-value-type' +
            ' type-value="$$node.type_value$$" ' +
            'ng-repeat="input in inputs track by $index" ' +
            'type="text" ' +
            'placeholder="Value ($$node.type_value$$)"' +
            'class="form-control" ng-change="changeArrayValue()" ' +
            'ng-model="node.value[$index]">' +

How to pass current value into: ng-change="changeArrayValue()"

I tried as: ng-change="changeArrayValue(node.value[$index])"

Upvotes: 0

Views: 1506

Answers (2)

aorfevre
aorfevre

Reputation: 5064

As I can see from your code; you are creating Angular JS directives / html code within your js file.

This is totally wrong ! !!! and you shall not do that. Add a proper template; than you can access to the value with ng-model

Upvotes: 2

Sangeet Singh
Sangeet Singh

Reputation: 13

I am not sure if what you are doing there is correct but if you have a value field in the input tag then I think you are looking for $event.target.value

Try ng-change="changeArrayValue($event.target.value)

Upvotes: 0

Related Questions