1

I have a form which is being used to edit some information. Form input fields get value generated by PHP. Before, I was using jQuery to edit and calculate values and get total value. Now I want to remove jQuery and use AngularJS during form edit. After I have searched in web for this editing solution, I could not find anything. Is it possible to edit values generated by PHP with AngularJS and calculate sum of values?

EDIT

Can I get those values in angularJS? If I try to get those values with ng-model, it gets nothing and makes those fields blank.

1 Answer 1

3

You could use an API call to your backend service to fetch the values and use those values in your AngularJS application.

Suppose you have a form like this in your application.

<form ng-controller="formController" ng-submit="someAction" method="post">
<input type = "text" ng-model="email"/>
</form>

And you want to populate value from your PHP to this email field. You can do it by making an API call to your backend service like this;

In your AngularJS controller;

var app = angular.module('YourApp');

app.controller('formController', function ($scope, $http) {
$http.get('API call to fetch data').success(function (data) {
  $scope.email = data.email;
});
});

Hope it helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.