Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.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
Angularjs 在URL中间的ID:_Angularjs - Fatal编程技术网

Angularjs 在URL中间的ID:

Angularjs 在URL中间的ID:,angularjs,Angularjs,我需要在工厂内获取此资源: Content: $resource("http://localhost:3000/matches/:id/content") 但当我尝试使用以下工具访问它时: Content.get({id: $scope.match.id}, function(){}); 我收到一个错误,因为它试图访问“/matches/content”而不是“/matches/123/content”(假设id为123) 我该如何解决这个问题呢?应该很好,这里是测试它的小提琴。你会不会说得

我需要在工厂内获取此资源:

Content: $resource("http://localhost:3000/matches/:id/content")
但当我尝试使用以下工具访问它时:

Content.get({id: $scope.match.id}, function(){});
我收到一个错误,因为它试图访问“/matches/content”而不是“/matches/123/content”(假设id为123)


我该如何解决这个问题呢?

应该很好,这里是测试它的小提琴。你会不会说得太早了


这里应该很好用的是测试它的小提琴。你会不会说得太早了


你的代码很好。问题是
$scope.match.id
解析为
未定义的
,这导致资源URL中省略了
:id
部分(重复的
/
也被删除)

要验证资源是否正常,请选中

Content.get({id: 123}, function(){});

还有
console.log($scope.match.id)
您的代码很好。问题是
$scope.match.id
解析为
未定义的
,这导致资源URL中省略了
:id
部分(重复的
/
也被删除)

要验证资源是否正常,请选中

Content.get({id: 123}, function(){});

还有
console.log($scope.match.id)

真可惜。。。你说得对。原因不明。真可惜。。。你说得对。原因是没有定义。
Content.get({id: 123}, function(){});