angular/angular.js — pull request #2312 by OrenAvissar (2013-04-06 05:28:45+00:00)
Title: feat(ngRemove): directive to remove a portion of the DOM tree (similar to ngHide)

I added a directive called `ngRemove` that I think could be useful. This works similar to `ngHide` except instead of setting the `display: none` css it will remove the element from the DOM.

There is already a comment in the code about refactoring `ngHide` *"//TODO(misko): refactor to remove element from the DOM"*. It seems to me `ngShow/ngHide` imply setting visibility rather than removing an element.

##### Some example cases when `ngRemove` is helpful:

When using bootstrap in the situation shown in the HTML snippet below the bootstrap css uses selectors like `.btn-group > .btn:first-child` and `.btn-group > .btn:last-child` to properly format a series of buttons. In this example if you just hide the last button `#btnCategories` using `display: none` the previous button `#btnUpload` won't be styled correctly -- the `#btnCategories` button needs to be removed from the DOM to trigger the `:last-child` selector on the `#btnUpload` button.

Home
Upload Document
Manage Categories

When using alternate inputs in a form (depending on application settings) it seems cleaner to remove the unused alternates instead of hiding them (in some cases they may share the same `name` or `id` attributes). As an example, the code below will use `radio` inputs if the application is set to only allow a single selection and `checkbox` inputs if multiple selections are allowed.

{{answerOption.text}}

{{slideData.submittext || "Submit"}}