0

I have the following code set up:

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

videoControllers.videoControllers('VideoDetailController', function($scope, $routeParams, $http){
    $http.get('http://localhost:8000/videos/api/video/' + $routeParams.videoId + '/?format=json').success(
            function(data){
                $scope.video = data;
            });
})

This code keeps giving me an error which state that: 'videoControllers.videoControllers is not a function'. The tutorial I am using is written in that manner and it is working, but my project gives me this error. Can anyone please help.

2 Answers 2

3

Becuase the keyword is controller while you are using videoControllers. Change your code as below:

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

videoControllers.controller('VideoDetailController', function($scope,  $routeParams, $http){
      $http.get('http://localhost:8000/videos/api/video/' +     $routeParams.videoId + '/?format=json')
       .success(function(data){
            $scope.video = data;
        });

});
Sign up to request clarification or add additional context in comments.

Comments

1

Try this coz in ur code ur not accessing controller

angular.module('videoControllers').controller('VideoDetailController', function($scope, $routeParams, $http){
    $http.get('http://localhost:8000/videos/api/video/' + $routeParams.videoId + '/?format=json').success(
            function(data){
                $scope.video = data;
            });
});

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.