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

directive templateUrl gives to No Controller Error #1903

Closed
jasonkuhrt opened this Issue Jan 28, 2013 · 14 comments

Comments

Projects
None yet
@jasonkuhrt

jasonkuhrt commented Jan 28, 2013

I am currently running into this exact issue

http://stackoverflow.com/questions/12006326/angularjs-templateurl-defers-construction-of-controller-dependent-code-breaks

I created an plunker

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

that appears to show everything ...working. However I am unable to reproduce this success in my application. Both versions of angularjs match (1.0.3) so my only guess is that templateUrl: 'foo.html' in plunker is not an accurate mechanism of my local server app's templateUrl: '../../parts/map/map.html'.

To be clear, in my app, if I inline the template templateUrl: '../../parts/map/map.html' then everything is totally fine.

Inline template: Works

Screen Shot 2013-01-28 at 4 57 09 PM

External template: Error

Screen Shot 2013-01-28 at 4 55 09 PM

One thing that struck me is the order of logging is different in the Error version: map controller fn comes AFTER map-marker link fn whereas when its working map controller fn comes BEFORE map-marker link fn.

Did I find a bug in angular or my head?

@ymauray

This comment has been minimized.

ymauray commented Jan 30, 2013

I have the exact same problem. So it's probably not in your head :).

I'll try to make a Plunker later.

Edit : here's my plunker

http://plnkr.co/edit/W1WZF8quqFUrttyEykS0

You can see the error in the JavaScript console :

Error: No controller: demoTable
    at Error (<anonymous>)
    at getControllers (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js:4114:19)
    at nodeLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js:4241:35)
    at delayedNodeLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js:4393:11)
    at compositeLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js:3840:14)
    at publicLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js:3763:30)
    at http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js:3845:29
    at new ngDirective.controller (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js:13734:5)
    at invoke (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js:2809:28)

If you uncomment line 23 of app.js and comment line 22, then there's no more error and everything works fine.

@ItsLeeOwen

This comment has been minimized.

Contributor

ItsLeeOwen commented Apr 1, 2013

Did you guys uncover any fixes, or workarounds for this issue? I am not sure why this is occurring in a new app I've just started as well.

@anthony-o

This comment has been minimized.

anthony-o commented May 15, 2013

I've got the same problem using Angular 1.1.4... when using 'templateUrl' + controller, I've got a "No Controller", and when I use only the 'template', then the problem disappear...

@ehelms

This comment has been minimized.

ehelms commented Jun 5, 2013

I have also recently stumbled across this exact same issue. Use of templateUrl in directives that use 'require: '^'' break with 'no controller' error.

@rohitmanusis

This comment has been minimized.

rohitmanusis commented Jun 6, 2013

Experiencing the same issue. Use of require '^' with templateUrl in directive gives 'no controller' error.

@cdmckay

This comment has been minimized.

cdmckay commented Jun 21, 2013

Also experiencing the same issue, even with 1.1.5. The solution I've used so far is to make the parent controller into a template instead of a templateUrl.

@darkpicnic

This comment has been minimized.

darkpicnic commented Jul 9, 2013

So have we confirmed it's the combo of termplateUrl and require?

@lc-nyovchev

This comment has been minimized.

lc-nyovchev commented Jul 15, 2013

Exact same problem on 1.0.7

@sja

This comment has been minimized.

sja commented Aug 5, 2013

@darkpicnic I've got the same problem on 1.1.5 with template and require: '^...

@ivarni

This comment has been minimized.

ivarni commented Aug 9, 2013

I am having this exact problem. I was just refactoring some directives from using template and inline HTML to using templateUrl and this exact issue popped up. I am also using require.
Observed in 1.0.5 and 1.0.7

@lrlopez

This comment has been minimized.

Contributor

lrlopez commented Aug 9, 2013

There is a commit (5c56011) that was merged some hours ago. It should have fixed this. If it does, it'd be nice to close the issue...

@btford

This comment has been minimized.

Contributor

btford commented Dec 20, 2013

Looks like it's working in 1.2.5 now: http://plnkr.co/edit/r27atiEDp2X422zvcnpV?p=preview

If this is still a problem and you can provide a broken demo on 1.2.x, I'll gladly re-open this for discussion. Thanks!

@btford btford closed this Dec 20, 2013

@SimplGy

This comment has been minimized.

SimplGy commented Dec 31, 2013

Could there be a regression on this for v1.2.7-build.2036+sha.e415e91? I'm trying to confirm using the plnkr but I don't think I can CDN to that build.

When I use require: '^directive' and templateUrl, I got the same error described here.

@caitp

This comment has been minimized.

Contributor

caitp commented Jan 1, 2014

I'm having trouble reproducing this, but I think the most likely thing that would cause this (in a modern build) is manually $compiling nodes without making use of the cloneConnectFn, which would cause the HTML compiler to not find the parent directives.

http://plnkr.co/edit/jqmhKsmLNr9DCAMkQJUz?p=preview here's an example, tested in a few builds (snapshot, 1.2.5 and 1.0.3), as far as I can tell this is always working as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment