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

Template of directive with replace:true is not compiling when directive is in another external template #1859

Closed
danilsomsikov opened this issue Jan 22, 2013 · 8 comments

Comments

@danilsomsikov
Copy link
Contributor

See http://jsfiddle.net/fuqwM/8/

IgorMinar pushed a commit that referenced this issue Feb 26, 2013
Passing DOMNode#childNodes to compileNodes when compiling remote
template, so that directives with replace:true can be compiled.
The previous version used jqLite#contents which returned collection
that was not updated during the compilation.

Closes #1859
@pheuter
Copy link

pheuter commented Jul 15, 2013

Running into this issue on Angular 1.1.5 while trying to test an element directive with replace: true:

beforeEach ->
    module 'app'

    inject ($rootScope, $compile) ->
      scope = $rootScope.$new()

      element = angular.element("<div>\n  <section name=\"Data\" icon=\"eye\"></section>\n</div>")

      $compile(element)(scope)
      scope.$digest()


  it 'should replace directive with template', ->
    console.log "ELEMENT: " + element.html()

In the test output, the html returns dom with the <section> directive instead the directive's template.

@petebacondarwin
Copy link
Contributor

where is your section directive definition? Is it loading the template asynch (i.e. using templateUrl)?

@pheuter
Copy link

pheuter commented Jul 16, 2013

Yes. In this particular scenario, $templateCache is used in a file loaded prior to the test.

@petebacondarwin
Copy link
Contributor

So in this case the template will be loaded async (even though it is in the cache). Can you check whether the directive is actually being compiled? Would you be able to provide a running example of the problem?

@pheuter
Copy link

pheuter commented Jul 16, 2013

Getting a weird error now when running on Plunker: http://plnkr.co/edit/ufrNwS3CPuFpDNy6LVoU?p=preview

TypeError: Cannot read property 'compile' of undefined

@pheuter
Copy link

pheuter commented Jul 16, 2013

Never mind the TypeError, I forgot to return the directive object definition. The problem of not replacing the directive template still persists though.

@pheuter
Copy link

pheuter commented Jul 16, 2013

@IgorMinar Any ideas?

@paulyoung
Copy link

This is an issue again as described in #3245.

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

Successfully merging a pull request may close this issue.

5 participants