Limit and Offset data results in AngularJS for Pagination

后端 未结 3 1255
伪装坚强ぢ
伪装坚强ぢ 2020-12-28 11:06

Does AngularJS have Limit and Offset request methods when calling an external data resource that supports them?

I imagine there is a more elegant solution than this,

3条回答
  •  情歌与酒
    2020-12-28 11:53

    I'm not sure I understand your question, but $http methods have a config parameter which is an object, one property of which is the "params" object:

    params – {Object.} – Map of strings or objects which will be turned to
    ?key1=value1&key2=value2 after the url. If the value is not a string, it will be JSONified.

    If your "limit" and "offset" values are in $routParams, then that seems like a fine place to get them from. However, you may want to consider wrapping the code that interfaces with your server into an Angular service. This service could store the current limit and offset values. You can inject the service into your controllers to get access to the functions (and/or data) that the service provides.

提交回复
热议问题