javascript - Error: argument {controller} is not a function, got undefined -


i'm trying write translation service based off of this post, i'm not able start debugging because keep getting error "error: [ng:areq] argument 'translationcontroller' not function, got undefined".

i've copied structure other controllers work fine, going wrong?

(partial app.js code)

}).when('/location', {         templateurl: "views/location/location.html",         controller: "translationcontroller" 

partial index.html code - ignore malformed html

script type="text/javascript" src="js/translationservice.js"></script script type="text/javascript" src="js/translationcontroller.js"></script script type="text/javascript" src="js/angular/i18n/angular-locale_en.js"></script 

translationcontroller.js

angular     .module('app')     .controller('translationcontroller', ['$scope', '$cookies', 'translationservice', function($scope, $cookies, $translationservice) {         $scope.translation;          var onsuccess = function (tx, r) {             $scope.$apply(function () {                 $scope.translation = r;         });          $scope.init = function () {             $translationservice.gettranslation(onsuccess, $scope, $cookies.lang);         }          $scope.init(); }]); 

translationservice.js

angular     .module('tde')     .factory('translationservice', ['$resource', function($resource) {         return {             translations : function(fn) {                 return gettranslation($resource, $scope, $cookies.lang);             }         };          this.gettranslation = function($resource, $scope, language) {             var languagefilepath = "js/translations/translation_" + language + ".json";             window.logger.logit("language path = " + languagefilepath);             $resource(languagefilepath).get(function (data) {                 $scope.translation = data;             })         } }]); 

partial location.html file:

<label>{{translation._experimenttitle_}}</label> 

after examining code seems forgot add '}' after onsuccess method

angular     .module('app')     .controller('translationcontroller', ['$scope', '$cookies', 'translationservice', function($scope, $cookies, $translationservice) {         $scope.translation;          var onsuccess = function (tx, r) {             $scope.$apply(function () {                 $scope.translation = r;         });        }// forgot add          $scope.init = function () {             $translationservice.gettranslation(onsuccess, $scope, $cookies.lang);         }          $scope.init(); }]); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -