I am using Angularjs, I have two api in method in factory method. I tried to access that two method one by one. but its not working.
We need to first print test1 then print test2.
Controller code:
app.controlle("Test").function($scope, factoryMethod) {
factoryMethod.test1().then(function(data) {
console.log(data);
console.log("test1");
}).then(factoryMethod.test2().then(function(data) {
console.log(data);
console.log("test2");
})).catch(function(data) {
alert(data);
});
}
Factory code:
app.factory("factoryMethod", function (){
//code for test1
//code for test2
});
Currently the console log print the following order: 1. test2 2. test1
Expecting test1 and than test2
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)