0

Hello I am new to AngularJs.

I like to get this edit_task with its id:

http://localhost:8080/edit_task/5629499534213120

I don't know how to get the ID into my function loadData().

This is a part of the app.js

$scope.editTask = function (id) {
    var config = {
        headers: {
            "CommandType": "editTask"
        }
    };


    function loadData() {
        $http.get("http://localhost:8080/edit_task/" + id ,data ,config).success(function (data) {
            $scope.tasks = data;
        });
    };

I couldend find any example ore documentation on this

Hope someone will help me on my way into Angularjs?

1 Answers1

0

In your app.js (or wherever you define your routes), define the id:

.when('/edit_task/:taskid', {
            templateUrl: 'TEMPLATEURL',
            controller: 'CONTROLLER_NAME',
        })

Then, in the controller inject $routeParams and query for the taskid:

APP.controller('CONTROLLER_NAME', function ($scope, $routeParams) {
     var taskId = $routeParams.taskid;
});
Tomer
  • 4,382
  • 5
  • 38
  • 48
  • Thanks Tomer. I will use your code and will see how this works out for me. What i see is that i need more understanding of AngularJs, and because I am comming from Python, I am not familiar with all this }}); – Hendrikus Godvliet Aug 22 '14 at 05:32