Zizzamia / ng-tasty

A tasty collection of reusable UI components for Angular, like grandma used to make. Like Table directive, WebSocket / Debounce / Throttle service, Range / Camelize / Slugify filters
MIT License
435 stars 64 forks source link

.success problem with angular 1.6.0 #232

Open p1lare opened 7 years ago

p1lare commented 7 years ago

Since angular 1.5 $http's deprecated custom callback methods - success() and error() - have been removed in angular 1.6. ngTasty needs some changes. https://docs.angularjs.org/guide/migration#migrate1.5to1.6-ng-services-$http

ng-tasty-tpls.js from 559 and 739 this code needs to be changed:


    if (scope.templateUrl) {
        $http.get(scope.templateUrl, { cache: $templateCache })
        .success(function(templateContent) {
        element.replaceWith($compile(templateContent)(scope));
      });
    }

to this:

    if (scope.templateUrl) {
        $http.get(scope.templateUrl, { cache: $templateCache })    
        .then(function onSuccess(response) {          
          element.replaceWith($compile(response.data)(scope));
        }, function onError(response) {
          console.log(response.status,response.statusText);
      });
    }

This maybe needs some confirmation, seems to work for me just fine. If the project is still alive I can make a pull request.

fdenzer commented 7 years ago

+1 same issue here: Angular 1.6.1 and some templateUrl-calls fail due to success being deprecated in 1.6.x