前几天项目需要,做了一个背景遮罩的弹出框,html采用js动态添加进去的,结果发现angularjs绑定在这里面不起作用,搜索下解决了,记录下:
1 var smallApplyParent = document.getElementById("smallApplyParent"); 2 angular.element(document).injector().invoke(function($compile){ 3 var scope = angular.element(smallApplyParent).scope(); 4 $compile(smallApplyParent)(scope); 5 });
代码运行会更新 smallApplyParent 里面的作用域;
哈哈,又可以愉快的玩耍了....