我有web应用程序,在这个web应用程序中,我有很多生成的输入组件。生成的组件依赖于用户输入参数,并动态添加到网页中。
其中一个参数是location picker。这不是必需的参数,因此它的生成也取决于用户输入。对于位置选择器,我使用http://jsfiddle.net/mrajcok/pEq6X/ angular指令。
我的问题是,当用户添加输入时,我添加了包含ng-app定义的生成代码,但这个组件无法工作,因为我需要以某种方式告诉angular再次解析html。有没有解决这个问题的方法?
<div ng-app="Otd" ng-controller="SearchForm">
<google-places location=location></google-places>
</div>发布于 2014-09-16 12:59:58
你可能想要使用AngularJs的$compile服务。
还有这个指南:http://docs.angularjs.org/guide/compiler
例如,Plunker Here
element.html(value); //Setting the HTML Content
// compile the new DOM and link it to the current
// scope.
// NOTE: we only compile .childNodes so that
// we don't get into infinite loop compiling ourselves
$compile(element.contents())(scope);https://stackoverflow.com/questions/25859493
复制相似问题