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.

ng-cloak elements should not show template binding braces and binding variables during ng-init #2927

@doliver3

Description

@doliver3

ng-cloak is showing template bindings during ng-init with an alert on Chrome, Firefox, and IE. ng-cloaked areas should never show template bindings braces and variables, and Angular should let the ng-init and template variable interpolation merge complete before showing the elements that are ng-cloaked.

If things go wrong during ng-init, it can be necessary to display a message to the user. It looks bad to still see the template braces and variable bindings behind the message. End users should never see the Angular templates unbound with braces and variable names.

Example shows template bindings appear during ng-init:
http://plnkr.co/edit/cLuIKsdKK9raWbxsmjBG?p=preview

Currently the angular code that removes the hidden styling of the ng-cloaked elements is executed before ng-init executes which is too soon.

CURRENT BEHAVIOR:
/* angular.js 1.1.5 code removes cloaked attribute during the compile phase and compile happens before ng-init which is too soon. Browser immediately renders without the css display:none that the ng-cloak class was providing. */
var ngCloakDirective = ngDirective({
compile: function(element, attr) {
attr.$set('ngCloak', undefined);
element.removeClass('ng-cloak');
}
});

REQUESTED BEHAVIOR:
/* One option for fixing this in the angular.js file is to delay until after the compile phase and ng-init are completed such as the following modification which changes when the ng-cloak class is removed to the link phase which happens after ng-init so the template bindings braces and variables are correctly not visible during ng-init... */
var ngCloakDirective = ngDirective({
link: function (scope, element, attr) {
attr.$set('ngCloak', undefined);
element.removeClass('ng-cloak');
}
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions