javascript - AngularJS $http.get Parameter -
i have simple code here , got stuck in passing parameter. here code:
route.js
function config($routeprovider) { $routeprovider .when('/edit/:id', { controller: 'updatetodoctrl', templateurl: 'app/views/edit-todo.html' }); }
index.html
<div ng-controller="someotherctrl"> <table> <tr ng-repeat="t in todos"> <a href="#/edit/{{ t.id }}">{{ t.name }}</a> </tr> </table> </div
controller
function updatetodoctrl($http, $scope) { function init() { $scope.todos = null; $scope.loading = true; $http.get('app/endpoints/edit-todo.php', { params: { todoid: //how id paramter } }); } }
as can ee in controller
, commented out part of problem. how can possibly pass id in url using $http.get
? thank you.
your :id
route parameter can :
function updatetodoctrl($http, $scope, $routeparams) { function init() { $scope.todos = null; $scope.loading = true; $http.get('app/endpoints/edit-todo.php', { params: { todoid: $routeparams.id } }); } }
Comments
Post a Comment