
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
angular-beacon
Advanced tools
Angular.JS directive which executes a callback when the view is fully rendered.
In Angular there's no way to know when it has finished rendering items on the screen. Controllers
emit $viewContentLoaded
and directives call postLink()
when Angular has finished cloning the
template, but that doesn't mean that DOM nodes were created yet, not that the page has been fully
rendered.
Wouldn't it be nice to be told when the page has been fully rendered? Unfortunately, Angular doesn't yet provide us a way to know that.
Some people suggest to wrap your DOM-interacting code inside a couple of nested $timeout
calls.
Others suggest to check the $digest
loop and do your stuff when the queue is empty. The former
solution doesn't always work and the latter may suffer from starvation in case you have a constant
stream of events coming from another source.
We know this is not the Angular way of doing things but, sometimes, it's unavoidable (additionally, we had to go this route in a couple of projects already).
Angular-Beacon repeatedly checks the DOM until all the elements you need become available (it will try for up to five seconds), then it invokes a callback function (which must have been defined in your scope) in which you can do all the DOM manipulation you want.
Add angular-beacon
to the list of dependencies in your Angular.JS application:
angular.module('myapp', [
'ngRoute',
// ...
'angular-beacon'
]);
Create a callback function in your controller's or directive's scope:
angular.module('myapp').controller('MyController', function ($scope) {
scope.myCallback = function () {
console.log('DOM Ready!');
};
});
In your view or template, add a reference to the beacon
directive, towards the
end of it:
<div class="my-panel">
...
</div>
<button>Push button</button>
<beacon waitfor=".my-panel, button" onready="myCallback"></beacon>
myCallback
will be called as soon as .my-panel
and button
appear on the page (as DOM nodes at
least).
That is: each beacon
directive instances expects two attributes:
onready
is the name of callback function defined inside the current Angular.JS scope which will
be called when the DOM is ready.waitfor
: A comma-separated list of CSS selectors, the same you would use with jQuery.FAQs
Angular.JS directive which executes a callback when the view is fully rendered.
The npm package angular-beacon receives a total of 1 weekly downloads. As such, angular-beacon popularity was classified as not popular.
We found that angular-beacon demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.