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

ng-model doesn't work with custom directive if the directive replaces content #4603

Closed
bratc opened this issue Oct 23, 2013 · 8 comments
Closed

Comments

@bratc
Copy link

bratc commented Oct 23, 2013

I've faced with following problem. I created directive that replace existing element with new one and used it like this:

When I ran this code I received an error:
Error: [$compile:ctreq] Controller 'ngModel', required by directive 'myDirective', can't be found!
http://errors.angularjs.org/1.2.0-rc.3/$compile/ctreq?p0=ngModel&p1=myDirective
at http://localhost:63343/demo-app/lib/angular/angular.js:78:12
at getControllers (http://localhost:63343/demo-app/lib/angular/angular.js:5288:19)
at http://localhost:63343/demo-app/lib/angular/angular.js:5294:24
at Array.forEach (native)
at forEach (http://localhost:63343/demo-app/lib/angular/angular.js:213:11)
at getControllers (http://localhost:63343/demo-app/lib/angular/angular.js:5293:11)
at nodeLinkFn (http://localhost:63343/demo-app/lib/angular/angular.js:5436:35)
at http://localhost:63343/demo-app/lib/angular/angular.js:5589:13
at http://localhost:63343/demo-app/lib/angular/angular.js:6672:11
at deferred.promise.then.wrappedCallback (http://localhost:63343/demo-app/lib/angular/angular.js:9769:81)

angular.js:8296

This directive works perfectly well with 1.2rc2 but doesn't work with 1.2rc3

@FedericoElles
Copy link

@bratc Are you using the template or templateUrl property to specify the HTML?
I had the same issue, but it did only occure if using templateUrl, but worked fine with template.

@bratc
Copy link
Author

bratc commented Nov 20, 2013

@FedericoElles I'm using templateUrl because in my case it's inconvenient to use template (far too big)

@roypeled
Copy link

Happened to me as well.
Using template is not a solution.

@mkondwilkar
Copy link

Is there a workaround for this? I need to use templateUrl.

@Narretz
Copy link
Contributor

Narretz commented Dec 17, 2013

There is no code in your post. Can you post the code or even better a plunker?

@bratc
Copy link
Author

bratc commented Dec 17, 2013

It works again with version 1.2.3 and later

@Narretz
Copy link
Contributor

Narretz commented Dec 17, 2013

@petebacondarwin This can be closed. Just pinging you because you seem to be currently closing some stuff.

@petebacondarwin
Copy link
Member

Thanks @Narretz . Please do ping me for issues that can be closed :-) Makes my day.

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

No branches or pull requests

6 participants