Using Inline Templates in AngularJS

前端 未结 2 739
情歌与酒
情歌与酒 2020-11-29 20:47

I wanted to load an inline view template.

I wrapped the template in a script tag of type text/ng-template and set the id to temp1.html. and

相关标签:
2条回答
  • 2020-11-29 21:18

    Ody, you were on the right track, the only problem was that the tags are outside of the DOM element on which the ng-app directive is used. If you move it to the <body ng-app="LearningApp"> element in-line templates should work.

    You might also find this question relevant: Is there a way to make AngularJS load partials in the beginning and not at when needed?

    0 讨论(0)
  • 2020-11-29 21:19

    Try use the id-Attribute of the script-Element to set the name of the template should work.

    <script type="text/ng-template" id="temp1.html">
       ... some template stuff
    </script>
    
    0 讨论(0)
提交回复
热议问题