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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -