Dynamically loaded input box does nothining

前端 未结 1 466
粉色の甜心
粉色の甜心 2021-01-27 10:17

So I have some html that gets loaded into the #panel div dynamically depending on which questionNumber the user is on. This is not all of the code but all of the relevant code I

1条回答
  •  不思量自难忘°
    2021-01-27 10:47

    If you add HTML to the DOM, you have to tell Angular to $compile it. This should be done in a directive. You'll need to inject $compile then do something like this:

    var content = '
    '; var compiled = $compile(content)(scope); // then put the content where you want

    Or better, define a directive and use a template, which will automatically get compiled for you by Angular.

    Other alternatives are ng-include (which will compile the loaded content for you) and ng-switch, which would allow you to put the templates into the HTML.

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