当我将数组传递给资源操作时...它不会将数组参数转换为URL参数数组
var Product = $resource('path/products');
Product.query({ids: [1,2,3]})
Run Code Online (Sandbox Code Playgroud)
而不是得到:
path/products?ids[]=1&ids[]=2ids[]=3
Run Code Online (Sandbox Code Playgroud)
我越来越:
path/products?ids=1&ids=2ids=3
Run Code Online (Sandbox Code Playgroud)
任何人都知道如何解决这个问题?
我创建了如下所示的路线:
Router::connect('/:api/:controller/:action/*', array(), array('api'=>'api'));
Router::connect('/:api/:controller', array('action' => 'index'), array('api'=>'api'));
Router::connect('/:api/', array('controller' => 'index', 'action' => 'index'), array('api'=>'api'));
Run Code Online (Sandbox Code Playgroud)
基本上,我希望通过特定端点发出的所有请求都以JSON响应.在上面的例子中,所有使用api前缀的请求.例如:
http://localhost/api/products
Run Code Online (Sandbox Code Playgroud)
应该返回JSON响应而不是HTML.请注意,即使没有定义.json扩展名,它也应该以这种方式工作.
我不是在谈论为产品添加属性,但我想添加一个属性本身..
你可以从产品 - >属性下的UI,但从代码中完成它(ei:要调用哪些函数或更新表)?