it is a good idea to reuse some function when we implement the project.
it is quite easy to do it in C#.
in AngularJS is a little tricky.
we must define the reference controller or service before we can use it to call the method.
here is the sample code to demostrate the approach.
customerApp.service('customerService', ['$http', function ($http) {
var self = this;
this.getCustomers = function ($scope) {
}
this.MergeCustomers = function ($scope) {
return $http({
method: "POST",
url: "/AngularJS/api/Customer/Customer",
dataType: 'json',
data: {
},
headers: { 'Content-Type': 'application/json' }
}).success(function (serverData) {
self.getCustomers($scope);
});
};
No comments:
Post a Comment