Restangular - getList 作为响应
Restangular - getList in response
你能告诉我我做错了什么吗?
var api = Restangular.all('person');
api.getList().then(function(data) {
angular.forEach(data, function(val,key) {
val.getList('role').then(function(res) {
//...
});
});});
我想打电话给 /person/:id/role ,但现在打电话给 /person/role ...
感谢任何建议
如果你想通过 id 获取一个人,你应该使用 Restangular.one('person', person.id) 这将创建 /person/:id/
谢谢@min che,现在工作正常。
解决方法:在angular.run()
Restangular.configuration.getIdFromElem = function(elem) {
// if route is person ==> returns idPerson
return elem["id"+elem.route.charAt(0).toUpperCase() + elem.route.slice(1)];
}
restangular 页面上的代码 -> here ... 在 angular.config() 中使用 RestangularProvider 对我不起作用
你能告诉我我做错了什么吗?
var api = Restangular.all('person');
api.getList().then(function(data) {
angular.forEach(data, function(val,key) {
val.getList('role').then(function(res) {
//...
});
});});
我想打电话给 /person/:id/role ,但现在打电话给 /person/role ...
感谢任何建议
如果你想通过 id 获取一个人,你应该使用 Restangular.one('person', person.id) 这将创建 /person/:id/
谢谢@min che,现在工作正常。
解决方法:在angular.run()
Restangular.configuration.getIdFromElem = function(elem) {
// if route is person ==> returns idPerson
return elem["id"+elem.route.charAt(0).toUpperCase() + elem.route.slice(1)];
}
restangular 页面上的代码 -> here ... 在 angular.config() 中使用 RestangularProvider 对我不起作用