Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Feature request: inverse version of ng-if: ng-notif? #15372

@poshest

Description

@poshest

I opened a Stackoverflow issue which describes the use case, which has yet to be answered satisfactorily.

In summary, I wish to use ng-if with one time binding for "initialisation" elements (stuff like "loading..." gifs), so that the element is removed from the DOM once the item is loaded AND the watch binding is then removed.

Basically I want an inverse version of ng-if. ng-hide works for this use case, but doesn't remove DOM elements. So perhaps "ng-notif"?

An alternative, more general case approach, might be to create a "remove watch binding upon..." feature. I propose the following syntax

ng-whatever=":removeBindingLiteral:expressionToEvaluate"

The idea is that when expressionToEvaluate becomes equal to removeBindingLiteral, which appears between the usual bind once ::, the binding (watch) is removed. This would make it possible to use ng-if in the manner in which I intend, vis

<img ng-src="/path/to/loading.gif" ng-if=":false:!vm.isLoading" />

The img will be displayed until the first time the expressionToEvaluate (!vm.isLoading) evaluates (===) to false, at which point the img will disappear from the DOM and the binding will be removed.

If there is a way to do this with the current Angular machinery, I'd love to know! :)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions