动态添加元素和删除元素

//通过$compile动态编译html

var html="<div ng-click='test()'>我是后添加的</div>";

var template = angular.element(html);

var mobileDialogElement = $compile(template)($scope);

angular.element("#"+id).append(mobileDialogElement);

 

// remove移除创建的元素

var closeMobileDialog = function () {

if (mobileDialogElement) {

  mobileDialogElement.remove();

}

 

相关文章:

  • 2022-02-09
  • 2022-01-05
  • 2022-12-23
  • 2021-11-12
  • 2021-12-26
猜你喜欢
  • 2022-12-23
  • 2021-10-17
  • 2021-12-21
  • 2022-12-23
  • 2021-05-25
  • 2022-02-08
  • 2021-12-25
相关资源
相似解决方案