CareiOS
V2EX  ›  Node.js

一篇不错的教程,分享给大家

  •  
  •   CareiOS · Jun 7, 2016 · 3606 views
    This topic created in 3692 days ago, the information mentioned may be changed or developed.

    http://www.ibm.com/developerworks/cn/web/wa-nodejs-polling-app/

    看完教程,学习了很多,但有一处没有看懂

    angular.module('pollServices', ['ngResource']).
              factory('Poll', function($resource) {
                return $resource('polls/:pollId', {}, {
                  query: { method: 'GET', params: { pollId: 'polls' }, isArray: true }
                })
              });
    

    这是 restful 请求, 为何 params :是{ pollId: 'polls' }, polls 在这儿是什么意思?

    2 replies    2016-06-07 09:54:54 +08:00
    klesh
        1
    klesh  
       Jun 7, 2016
    代表 Poll.query({ polls: 123}) 会去请求 polls/123 这个 url
    CareiOS
        2
    CareiOS  
    OP
       Jun 7, 2016
    @klesh 那这儿我可以乱写,比如写成:
    ```
    params: { pollId: 'id' }
    ```
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5767 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 03:07 · PVG 11:07 · LAX 20:07 · JFK 23:07
    ♥ Do have faith in what you're doing.