app.service('JavascriptReflection', function($q, JSONStoreAPIServ) {
var Login = function() {
var self = this;
self.Name="";
self.find = function() {
//Call Ionic Service Here
var dataFromDatabase = JSONStoreAPIServ.findLogin(self.Name);
console.log('You are finding login ' + dataFromDatabase);
}
}
var Customer = function() {
var self = this;
self.Name = "";
self.find = function() {
var dataFromDatabase = JSONStoreAPIServ.findCustomer(self.Name);
console.log('You are finding Customer ' + dataFromDatabase);
}
}
var Database = function() {
var self = this;
self.find = function(obj) {
if (typeof obj.find == 'function') {
obj.find();
}
}
}
});
//At Controller.js
var db = new JavascriptReflection.Database();
var cust = new JavascriptReflection.Customer();
cust.Name = "Terry";
db.find(cust);
我想要实现的是我的Javascript对象能够访问Ionic Service。或者Ionic Service能否具有相同的对象行为(如上面的代码所示)。 Ionic Service可以拨打另一个Ionic服务吗? (应该可以通过注入服务名称)。如果我错了或Ionic有其他方法可以达到同样的目标,请纠正我吗?