Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/415.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 来自AngularJS和查询字符串的Restful API调用_Javascript_Angularjs_Express - Fatal编程技术网

Javascript 来自AngularJS和查询字符串的Restful API调用

Javascript 来自AngularJS和查询字符串的Restful API调用,javascript,angularjs,express,Javascript,Angularjs,Express,我目前正在开发一个具有编辑功能的web应用程序 目前,我构建了一个包含所有包含id的记录列表的页面 因此,当我单击“编辑”按钮时,它会执行以下操作: $state.go('editCustomer', { customerObj: customer }); 然后,这将指向编辑页面,该页面显示正确的记录,并预先输入正确的数据 但是,我希望通过单击编辑按钮创建一个类似于以下内容的url:/customer?id=12345 当编辑页面加载时,它将从查询字符串中获取id,并使用$resource调

我目前正在开发一个具有编辑功能的web应用程序

目前,我构建了一个包含所有包含id的记录列表的页面

因此,当我单击“编辑”按钮时,它会执行以下操作:

 $state.go('editCustomer', { customerObj: customer });
然后,这将指向编辑页面,该页面显示正确的记录,并预先输入正确的数据

但是,我希望通过单击编辑按钮创建一个类似于以下内容的url:/customer?id=12345

当编辑页面加载时,它将从查询字符串中获取id,并使用$resource调用get

所以我的问题是我怎样才能做到这一点?我是否需要更改服务器端的api路由以适应当前get的如下情况

router.get('/:id', controller.show);
任何帮助都会很好

谢谢

使用:


谢谢你的回复。我会尝试一下,但我已经读过了,应该会成功的
<a ui-sref="editCustomer({ id: customer.id })">Edit</a>
$stateProvider
  .state('editCustomer', {
    url: '/customer/:id',
    // etc ...
  });