我正在使用angularjs和rails,我想像这样调用rails controller
.controller('SongController', ['$scope','FileUploader','$stateParams',function($scope, FileUploader,$stateParams) {
$scope.uploader = new FileUploader({url: '/events/$stateParams.id/playlists'});
}]);
$ stateParams.id应该被event_id替换为1或2,url就像
/events/1/playlists
但事实并非如此
它给了我以下错误
No route matches [POST] "/events/$stateParams.id/playlists"
如何拨打路线。
答案 0 :(得分:1)
您需要插入实际ID:
.controller('SongController', ['$scope','FileUploader','$stateParams',function($scope, FileUploader,$stateParams) {
$scope.uploader = new FileUploader({url: '/events/' + $stateParams.id + '/playlists'});
}]);