0

i'm pretty new to AngularJS and i have a little problem.

I receive JSON data from an api, I display all the data with ng-repeat.

Then from each different object, when I click on Id link for exemple, i would like to display in another page only the specific data for this object. I don't have any problem with the route, I go fine to the page, but when i try form exemple to display the "Name", i get this : {{name}}

Here go my two controllers :

    var toulouseVeloControllers = angular.module('toulouseVeloControllers', []);

toulouseVeloControllers.controller('toulouseVeloListCtrl', ['$scope', '$http',
  function($scope, $http) {
    $http.get('https://api.jcdecaux.com/vls/v1/stations?contract=toulouse&apiKey=************************').success(function(data) {
      $scope.bornes = data;
    });
  }]);

    toulouseVeloControllers.controller('toulouseVeloDetailCtrl', ['$scope', '$routeParams', '$http',
      function($scope, $http) {
        $http.get('https://api.jcdecaux.com/vls/v1/stations/' + data.number + '?contract=Toulouse&apiKey=*******************************').success(function(data) {

      $scope.name = data;
    });
  }]);

Does someone can help ?

Thank you a lot !

4
  • Can you make a plunker? It helps us to help you. Commented Jul 21, 2015 at 12:45
  • post your problematic code also not only working code Commented Jul 21, 2015 at 12:46
  • @Hiru He could not address the problematic code bro, that why he asked. Commented Jul 21, 2015 at 12:54
  • Always watch at the javascript console, it could save you a lot of time. The mistake @Rikky found should actually be displayed in the console. Commented Jul 21, 2015 at 12:56

1 Answer 1

2
 toulouseVeloControllers.controller('toulouseVeloDetailCtrl', ['$scope', '$routeParams', '$http',
  function($scope, $http) {....

This one is the problem, you have not injected enough dependencies in to the controller. Fixing it by add the $routeParams dependency to the controller. Like this:

 toulouseVeloControllers.controller('toulouseVeloDetailCtrl', ['$scope', '$routeParams', '$http',
  function($scope, $routeParams, $http) {....
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.