There is the following task - to output an array of data using AngularJS. Part of the data is presented in numerical form and is placed in the input.
Accordingly, the value in this input can be edited and passed back to the API.
In code, the input looks like this:
<input type="number" ng-model="product.price"> The task is to ensure that the existing ng-model value, both during initialization and when data is changed, is not equal to that returned by the API, but, for example, divided by 10.
Is it possible to implement this?
I read many manuals and similar questions, but I could not find a solution. Thank you in advance!
UPDATE Not quite successfully put it in the question: The bottom line is that I want this type of construction
<input type="number" ng-model="product.price / 10"> worked. That is, not only displayed the data, as is happening now, but also allowed to send this data.
UPDATE 2 The task is also complicated by the fact that I output the dataset using ng-repeat. That is, the final construction is as follows:
<table> <tr ng-repeat="product in products"> <td>{{ product.name }}</td> <td><input type="number" ng-model="product.price"></td> </tr> </table> UPDATE 3 Also add an example of the controller code:
directApp.controller('campaignController', function($scope, $http, $routeParams) { $http({ method: 'GET', url: 'url_to_get_data_from' }).success(function(data) { $scope.products = data; }); });
product.pricewhy would you doproduct.price = value / 10instead ofproduct.price = valuein the place of filling? - Grundy