Multiple directives asking for templates on

后端 未结 13 1754
长情又很酷
长情又很酷 2021-01-07 18:18

I have the following HTML:

相关标签:
13条回答
  • 2021-01-07 18:25

    Both of your directives are trying to replace the element in the dom. Try removing the the replace: true lines in your directive definition object.

    0 讨论(0)
  • 2021-01-07 18:26

    In my case, I had a reference to a missing file in the BundleConfig, I removed the reference and it started to work.

    0 讨论(0)
  • 2021-01-07 18:28

    For me, this was caused by multiple copies of the directive and template existing in the dist directory caused by grunt building without cleaning (during a watch task). A clean and rebuild solved this for me.

    0 讨论(0)
  • 2021-01-07 18:32

    You can’t have one (element) directive directly referencing another (element) directive. Wrap it with a <div>, e.g:

    template: '<div><my-custom-directive>'
            + '</my-custom-directive></div>'
    

    See https://github.com/angular/angular.js/issues/5428 for more information.

    0 讨论(0)
  • 2021-01-07 18:40

    For Visual Studio users using TypeScript, this got me. I'd renamed my typescript file and the built .js file was in the directory (but it doesn't show up in the project). I had to show all files in the directory to remove the lingering unused *.js files.

    0 讨论(0)
  • 2021-01-07 18:40

    (in case it helps someone else)

    For me the issue was having a backup file (i.e. .bkp.html) which was just an old copy of a template I was using for reference - but this was being included by karma since it matched the ".../**/*.html" pattern.

    0 讨论(0)
提交回复
热议问题