Recommendations for adding / editing data using AngularJS

I am currently developing a SPA application using AngularJS, which allows end users to add and edit orders through a form.

What I would like to know is what is considered best practice for determining if an application is in state Editor Create?

For example, when I click on a menu item that says “Add a new order,” I expect a partial view called `order.html 'to appear blank with all input fields. If possible, I would also like to reuse the same view when editing an order with input fields pre-populated from the current editable order.

Is it necessary to use service/factoryfor this, which has the property to determine the state, for example:

angular.module('app')
    .factory('orderService', ['$http', function($http) {
        var state = {
            addOrder: false,
            order: {
                orderRef: "",
                orderDate: ""
            }
        };
    }]);

Then I could set the property addOrderfrom the corresponding controller in accordance with the editing state, and also fill the property orderwith order details when addOrder: true.

I looked through the network, unfortunately, there seem to be few such examples of this.

+4
source share
1 answer

(DataRepo), , . , input, , , .

<input type="text" ng-model="DataRepo.orderNotes">

DataRepo :

$scope.DataRepo = DataRepo;

, DataRepo.

+1

All Articles