J
J
junart2015-10-29 23:41:54
Angular
junart, 2015-10-29 23:41:54

How to load data via AJAX in Angular JS at a given URL?

There is a URL like this: /home/1
How can I find this URL and call a method in an Angular JS controller?
Tried using routing:

.when("/home/:id", {
                        templateUrl: " ",
                        controller: "TestController",
                        resolve: {
                            message: function(app, helpers, $route){
                                console.log($route);

                                return app.get({
                                    user: 533,
                                    id: 2

                                }).then(function (response) {
                                    console.log($route);
                                    return helpers.toArray(response.app);
                                });
                            }
                        }
                    });

But in the body of `message: function(app, helpers, $route){` I get nothing in `console.log($route);`

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Tonkonozhenko, 2015-10-31
@Tonkonozhenko

$stateParams in the controdder is fine for this.

A
Andrei, 2015-10-29
@R0dger

Just like in JavaScript

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question