Skip to content

Error: undefined is not an object (evaluating 'directive.messages') #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tlvince opened this issue Dec 9, 2014 · 10 comments
Closed
Labels

Comments

@tlvince
Copy link

tlvince commented Dec 9, 2014

Any idea what's going on here? plunkr.

addMessage@https://raw.githubusercontent.com/JanStevens/angular-growl-2/master/build/angular-growl.js:315:31
broadcastMessage@https://raw.githubusercontent.com/JanStevens/angular-growl-2/master/build/angular-growl.js:193:52
sendMessage@https://raw.githubusercontent.com/JanStevens/angular-growl-2/master/build/angular-growl.js:222:32
info@https://raw.githubusercontent.com/JanStevens/angular-growl-2/master/build/angular-growl.js:231:27
http://run.plnkr.co/wEbSdNT3pnBuUoIq/app.js:4:13
invoke@https://code.angularjs.org/1.3.5/angular.js:4138:22
@JanStevens
Copy link
Owner

Hello,

I've edit it using my settings from the code pen examples. It seems that there is a bug (or not dont know yet) that you should use the growls as an action or result of something.

http://plnkr.co/edit/SLWeLg8gOzXWodatWng3?p=preview

I've added a button that can be clicked and this toggles a growl notification. I dont know in what usecase you should instantly show a growl when the controller is initialized (something odd happens then). I can look into it

@tlvince
Copy link
Author

tlvince commented Dec 10, 2014

Yeah, my example is contrived (a reduced test case to demonstrate the bug), though I'll frequently trigger a growl from a service (i.e. not from a user-facing interaction) e.g. when an XHR call has failed.

@punund
Copy link

punund commented Dec 10, 2014

+1, I am seeing this too.

@boxfrommars
Copy link

same error

TypeError: Cannot read property 'messages' of undefined
    at addMessage (angular-growl.js:298)
    at broadcastMessage (angular-growl.js:193)
    at sendMessage (angular-growl.js:222)
    at Object.success (angular-growl.js:234)
    at regionView.js:52
    at processQueue (angular.js:13075)
    at angular.js:13091
    at Scope.$get.Scope.$eval (angular.js:14291)
    at Scope.$get.Scope.$digest (angular.js:14107)
    at Scope.$get.Scope.$apply (angular.js:14395)

@JanStevens
Copy link
Owner

I think this is a loading issue or async issue, it works with a button or a server response, I'll look into it this week

@nathasm
Copy link

nathasm commented Dec 11, 2014

I've run in to this issue when unit testing my code that calls the growlMessages service without the directive.

Essentially initDirective is never called so this.directives[referenceId] is undefined.

In my unit tests I had to do something like:

beforeEach(inject(function ($injector) {
  var $compile = $injector.get('$compile');
  var element = angular.element('<div growl></div>');
  $compile(element)($scope);
}));

@gmhenderson
Copy link

+1, running into this as well.

@noahkeitel
Copy link

+1 I'm getting this error too.

@callicles
Copy link

+1 ran into this while unit testing too

@preston
Copy link

preston commented Feb 19, 2015

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants