简体   繁体   English

Angular.js侦听器,用于新的DOM元素

[英]Angular.js listener for new DOM elements

We have a library which creates custom input fields for radiobuttons and checkboxes. 我们有一个库,可为单选按钮和复选框创建自定义输入字段。
The library is cloning DOM elements. 该库正在克隆DOM元素。 After cloning them, Angular stuff like models are not working anymore. 克隆它们之后,Angular之类的东西不再起作用。
Here is a little example of the issue: http://jsfiddle.net/7oxq8vka/1/ 这是问题的一个小示例: http : //jsfiddle.net/7oxq8vka/1/
How can I tell Angular to listen for DOM changes and update its listeners? 如何告诉Angular侦听DOM更改并更新其侦听器? Like myApp.updateDom(); 就像myApp.updateDom();
Or if that is not possible, how can I add these listeners outside of the Angular code? 还是如果不可能,如何在Angular代码之外添加这些侦听器? Is it possible to do something like myApp.addListener($(this)); 是否可以做类似myApp.addListener($(this));事情myApp.addListener($(this));

 var myApp = angular.module('myApp', []);

 myApp.controller('my', function($scope){
    $('.custom').each(function() {
        var clone = $(this).clone().removeClass('custom');        
        $(this).after(clone).remove();        
    });        
 });

Here : http://jsfiddle.net/7oxq8vka/6/ 此处: http : //jsfiddle.net/7oxq8vka/6/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM