如何去除角JS所有子元素 [英] how to remove All child element in Angular js

查看:88
本文介绍了如何去除角JS所有子元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我如何删除父分区的所有子元素。

Can anyone tell me how to remove all child element of parent div.

假设有ul元素。 UL有3个孩子的。所以我想删除这个孩子,并重新绘制新的童车。所以这就是为什么我需要删除UL的所有孩子。

Suppose there is ul element. ul has 3 childs. so i want to remove this child and redraw new childs. so that's why i need to remove all child of ul.

谁能帮助我?

推荐答案

这听起来并不像一个特别角度-Y的事情 - 你想太低级

That doesn't sound like a particularly Angular-y thing to do -- you're thinking too low-level.

如果你有东西的清单要显示:

If you have a list of stuff you want to display:

$scope.myStuff = [42, 35, 76];

您可以用类似做

<ul>
  <li ng-repeat="x in myStuff"> {{ x }} is a cool number </li>
</ul>

然后,只需更新 $ scope.myStuff 和角度会自动照顾重绘的。

Then just update $scope.myStuff and angular will take care of the redrawing automatically.

http://docs.angularjs.org/api/ng.directive:ngRepeat

请参阅 http://jsfiddle.net/H3sC2/1/ 一个例子。

这篇关于如何去除角JS所有子元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆