doshprompt / angular-localization

angularjs localization done right.
http://doshprompt.github.io/angular-localization
MIT License
159 stars 79 forks source link

Throwing http exception #114

Open milindCODEROR opened 7 years ago

milindCODEROR commented 7 years ago

As per the document, I implemented the localization but its throwing the below exception TypeError: $http.get(...).success is not a function

I am using angular: 1.6.x version

doshprompt commented 7 years ago

Can you give an example of your code?

alphatwit commented 6 years ago

It's because Angular 1.6 doesn't support .success. you have to use .then

https://stackoverflow.com/questions/41169385/http-get-success-is-not-a-function

angel1st commented 6 years ago

@doshprompt - what you should do is to replace your $http.get(...) call at line 106 with following code:

                    $http.get(url)
                        .then(function (data) {
                            var key,
                                path = getPath(token);
                            // Merge the contents of the obtained data into the stored bundle.
                            for (key in data) {
                                if (data.hasOwnProperty(key)) {
                                    root[key] = data[key];
                                }
                            }

                            // Mark the bundle as having been "loaded".
                            delete root._loading;

                            // Notify anyone who cares to know about this event.
                            $rootScope.$broadcast(localeEvents.resourceUpdates);

                            // If we issued a Promise for this file, resolve it now.
                            if (deferrences[path]) {
                                deferrences[path].resolve(path);
                            }
                        }, 
                        function (data) {
                            $log.error("[localizationService] Failed to load: " + url);

                            // We can try it again later.
                            delete root._loading;
                        });

and since the pull request is already made, it shouldn't be a hard to be implemented, I guess....