Angular directive templateUrl won't render on script tag

馋奶兔 提交于 2019-12-25 09:35:02

问题


Originally, I had asked why the partial that I've defined in my controller and ng-template won't populate the modal.

After having no success loading any directive on the script tag - I believe that the routing method we are using is what is circumventing the script from finding the partial.

The directive's templateUrl returns 404 when invoked via the modal ng-click="open()". Everything resolves correctly if invoked on other elements.

Directive loads templateUrl on div:

<div data-modal-partial-directive></div>

Directive templateUrl returns 404 on script:

<div ng-controller="ModalDemoCtrl">
    <script type="text/ng-template" 
        data-modal-partial-directive>
    </script>

    <button class="button" ng-click="open()">Open me!</button>
</div>

What's even more confounding is that the controller logs that the modal was dismissed. Which means that everything else is running smoothly, except that 404 stops the content from loading, which closes the modal.

Does this sound familiar to anyone's use case? Is there a way around it?

来源:https://stackoverflow.com/questions/27629290/angular-directive-templateurl-wont-render-on-script-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!