Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Error message on directive namespace conflict #11775

Closed
sod opened this issue Apr 30, 2015 · 8 comments
Closed

Error message on directive namespace conflict #11775

sod opened this issue Apr 30, 2015 · 8 comments

Comments

@sod
Copy link

sod commented Apr 30, 2015

I got this error message today:

Error: [$compile:multidir] Multiple directives [pagination, pagination] asking for new/isolated scope on: <pagination>
http://errors.angularjs.org/1.4.0-rc.1/$compile/multidir?p0=pagination&p1=pagination&p2=new%2Fisolated%20scope&p3=%3Cpagination%3E

Took me a while to debug whats wrong with my pagination directive. Until I discovered another directive with the exact same name pagination from ui.bootstrap. It wasn't obvious as I didn't include ui.boostrap myself.

If the error message would include the module name the directive came from, this had helped a lot. Something like:

Error: [$compile:multidir] Multiple directives [pagination (module: foundation), pagination (module: ui.bootstrap)] asking for new/isolated scope on: <pagination>

Example code: http://plnkr.co/edit/Mgxutpvfr4ngqRD6fV1F?p=preview
Version: angular.js/1.4.0-rc.1

@petebacondarwin
Copy link
Contributor

Feel free to provide a PR for this. Otherwise we will try to get to it in 1.5. At the moment there is no link back from injectable components to their originating modules.

kentcdodds pushed a commit to kentcdodds/angular.js that referenced this issue May 2, 2015
@kentcdodds
Copy link
Member

Trying my hand at a PR #11793. Would love some feedback to make sure I'm taking this the right direction. A little iffy on the idea of passing the module to all the invoke queue. But I can't think of any other way to accomplish this.

@lugovsky
Copy link
Contributor

lugovsky commented May 4, 2015

@kentcdodds Probably there could be other way to do this. I'm just not 100% sure if this is possible, cuz I'm fairly new to angular.js sources.

I assume, that each directive is an object. If so, there could probably be a way to find module in which directive is defined by using object comparison. Even if this solution is not good in terms of performance, I think it could be quite okay during exception throwing.

And again, it's only an assumption, so don't judge me strictly please :)

As well I can provide pull request, if this solution is implementable and somebody will tell me which parts of it are not implemented at all.

@petebacondarwin
Copy link
Contributor

It would be better find a way to search the loaded modules for directives with a given name.

@kentcdodds
Copy link
Member

That could be reasonably done. I've done this before (the list on the left is auto-generated based on the contents of the _invokeQueue). That would also touch much less of the entire library.

@lugovsky
Copy link
Contributor

lugovsky commented May 5, 2015

Yeah, I see that. But in your example you have root module hardcoded:

var allTheThings = [];
  _.each(angular.module('kcd').requires, function(submoduleName) {
    allTheThings = _.union(allTheThings, getThings(angular.module(submoduleName)));
  });

As from what I understand, in real application this information is available only on injector level. That's why from my point of view, the only way to achieve what we want is to make injector expose list of loaded modules here: https://github.com/angular/angular.js/blob/master/src/auto/injector.js#L838

Guys, am I heading in the right direction? Can I go on with that and create a pull request?

@petebacondarwin
Copy link
Contributor

@lugovsky if you have a solution that does not impact the runtime performance and is cleanly implemented then by all means make a pull request.

lugovsky added a commit to akveoDev/angular.js that referenced this issue May 7, 2015
Show module name if possible when multidir error happens.

Closes angular#11775
@lugovsky
Copy link
Contributor

lugovsky commented May 7, 2015

Hey guys. I finally created a pull request for this issue. Please check it out and tell, does it look good enough for you. I will be happy to do any modifications

lugovsky added a commit to akveoDev/angular.js that referenced this issue May 18, 2015
Code cleanup as angular team suggested.

Closes angular#11775
lugovsky added a commit to akveoDev/angular.js that referenced this issue May 19, 2015
Show module name if possible when multidir error happens.

Closes angular#11775
netman92 pushed a commit to netman92/angular.js that referenced this issue Aug 8, 2015
Show module name if possible when multidir error happens.

Closes angular#11775
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.