bafix2203
bafix2203

Reputation: 541

Number from input AngularJS

I wan't to show in console.log $scope.value from input in which I have chosen the number, after click.

My code :

 <table class="table table-bordered table-striped">
                        <thead>
                        <tr>
                            <th >Name
                            <th >System
                            </th>
                            <th>Actions</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr ng-repeat="n in data">
                            <td style ="word-break:break-all;">{{n.name}}</td>

                            <td style="width:35px;">{{n.system}}</td>
                            <td><input class="form-control input-sm" type="number" name="input" ng-model="value"
                                       min="0" max="100" style="width:55px;">
                                </td>

                        </tr>
                        </tbody>
                    </table>
                    <button ng-click="postapi()">Value</button>

Plunker : http://plnkr.co/edit/g1t4pludTTIAJYKTToCK?p=preview

Thanks for answers in advance!

Upvotes: 0

Views: 31

Answers (1)

MrWook
MrWook

Reputation: 348

You can't access the value that you define inside the ng-repeat because the ng-repeat create it's own scope. And what i know is that you can't access a child scope from a parent scope.

It will be better if you change ng-model="value" to ng-model="n.value". Then you can access the value over the object

Upvotes: 1

Related Questions