alexcrack / angular-ui-notification

Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating
MIT License
536 stars 169 forks source link

$http.get(...).success is not a function angular 1.6 #106

Closed okosowski closed 7 years ago

okosowski commented 7 years ago

with angular v1.6.0-rc.0, any use Notification throw

TypeError: $http.get(...).success is not a function
cklemming commented 7 years ago

Yes, in Angular 1.6 the $http Success/Error callback methods have been deprecated.

They should be replaced by .then(...) everywhere in this library.

celsomtrindade commented 7 years ago

Besides this change (.then())

line 56
$http.get(args.template,{cache: $templateCache}).then(function(template) {

line 189
}, function(data){

I'm also facing some issues related to jqLite when usin .bind(). Around this line:

line 126
if (args.closeOnClick) {
    templateElement.addClass('clickable');
    templateElement.bind('click', closeEvent);
}
MikhailRoot commented 7 years ago

https://github.com/MikhailRoot/angular-ui-notification working with angular 1.6 also I've added direct templateCache loading if we load default template which is present in ui-notification module. I've submited edits As PR

teklakct commented 7 years ago

As @cklemming says, in Angular 1.6 $http Success/Error callback methods have been deprecated.

$http's deprecated custom callback methods - success() and error() - have been removed (...) but note that the method signatures and return values are different.

Due to b54a39

You should find more info in about changes with $http in migration guide.

cropcrop commented 7 years ago

@alexcrack Any chance @MikhailRoot 's solution will be merged? It would be great to have this callbacks deprecation fixed soon as many angular projects are broken after upgrading to angular 1.5.9+

MikhailRoot commented 7 years ago

Hi ! i've updated bower.json to resolve properly for angular 1.5.x and 1.6 of package so untill our PR will be merged to master you can specify fork with fixes in your bower.json file with this line:

"angular-ui-notification": "MikhailRoot/angular-ui-notification#0.3.4",

in your dependencies section.

cropcrop commented 7 years ago

Great! Thank you @MikhailRoot

edgaraskazlauskas commented 7 years ago

@MikhailRoot Do you not get the "Template (http://**path**.html) could not be loaded. TypeError: element.addEventListener is not a function" error?

MikhailRoot commented 7 years ago

@interruptr this exception is Thrown in code just like in previous versions, if Notification service can't access template neither from templateCache nor from $http. Also what do you mean by http://path.html as path to your template. There are some points to consider:

  1. Do you preload your template into template cache? (with nghtml2js or something like that)
  2. Do you use this module in Cordova\PhoneGap app? - if so - I found the best approach is to use preloaded into templateCache templates, and specifying path's to them like /templates/yourtemplate.html
  3. May be I'm wrong but in general it's not a good idea to try to get template from fully qualified url like you've provided in example. At least i've never seen this in code. If you are developing website you can specify relative path(better starting from forward slash like /partials/templatename.html ), but much better - use templateCache with preloaded templates - with this approach you'll overcome a lot of troubles with relative paths of your app and templates.
edgaraskazlauskas commented 7 years ago

@MikhailRoot I require it with webpack and insert the template into template cache (not a cordova app). I found a workaround for this - if I add a template into templateCache with the name of the default template ("angular-ui-notification.html") then it works. Otherwise the error described above gets thrown... It's quite interesting. I will look into the issue a bit later.

MikhailRoot commented 7 years ago

@interruptr Thank you for investigation and insight, i've updated code to check templateCache first both default and custom specified template names. Latest fixes with update in bower.json

"angular-ui-notification": "MikhailRoot/angular-ui-notification#0.3.5"

then bower update

tonylampada commented 7 years ago

I've submitted #109 just in the case @alexcrack is in a hurry and can't find the time to give the deserved attention to @MikhailRoot 's #108

bhaveshvyas007 commented 7 years ago

Please fix this asap...

MikhailRoot commented 7 years ago

@bhaveshvyas007 as i mentioned above untill fixed or merged use

"angular-ui-notification": "MikhailRoot/angular-ui-notification#0.3.5"

in your bower.json then update. works with angular 1.6

jebberwocky commented 7 years ago

@MikhailRoot guess that we need to use your branch for now

alexcrack commented 7 years ago

Merged @MikhailRoot's pull-request.