Home > Back-end >  How to implement the service layer in the presents a method in another call the method call
How to implement the service layer in the presents a method in another call the method call

Time:11-29

Presents both before and after the end of the separation, the service level of the default method is an asynchronous call, but there is a mall project requirements:

I click modify merchants: need to merchants query first, and then displayed on the page changes, but the echo business information of the controller and business belongs to modify the page is not a controller, the binding on my page there is a problem: when I was

I can introduce page a controller, so I began to introduce the loginService sellerController, although it can call for to the businessman information, but the call time display of the dealer initialization method and page according to business ID query business always has no order, this is no good, you must first get the businessman ID

To the realization of online presents a synchronous invocation method are many, but helpless beginner, are discussed, and today I'll use a clumsy but especially easy to understand the way the implementation calls!

//initialize merchants query information
//initialize method is called information, in a method is called after the callback function as a parameter called the second call, can realize the asynchronous call
$scope. InitSellerMess=function () {
$scope. SearchLoginName ($scope. The findOne);
}

//query sellerId
{$scope. SearchLoginName=function (findOne)
LoginService. LoginName () success (
Function (response) {
$scope. The loginName=response. LoginName;
FindOne ($scope. The loginName);
}
);
}
//query entity
{$scope. The findOne=function (loginName)
Seven-letter sellerService. FindOne (loginName).
Function (response) {
$scope. The entity=response;
}
);
}

, as shown in the code page to initialize method call initSellerMess (); Then call query businessman ID method, the second method is passed as a parameter to call in, in searchLoginName () method call is completed, will business query ID as a parameter to invoke business methods, can be realized!
  • Related