ng-model doesn't work with custom directive if the directive replaces content
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)
This directive works perfectly well with 1.2rc2 but doesn't work with 1.2rc3
@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.
@FedericoElles I'm using templateUrl because in my case it's inconvenient to use template (far too big)
Happened to me as well. Using template is not a solution.
Is there a workaround for this? I need to use templateUrl.
There is no code in your post. Can you post the code or even better a plunker?
It works again with version 1.2.3 and later
@petebacondarwin This can be closed. Just pinging you because you seem to be currently closing some stuff.
Thanks @Narretz . Please do ping me for issues that can be closed :-) Makes my day.