How to add visjs events in angularjs?

There is an event in visjs docstabilizationProgress that I need to include in my angularjs project. I created a plunker demo for the same.

I tried something like below, but not sure how to add a progress bar using angular ones. Here is a link to give an idea

<vis-network data="data" options="options" events="events"></vis-network>

Controller code

$scope.events = [{
    stabilizationProgress: function (obj) {

    },
    stabilizationIterationsDone: function () {

    }
}];
+4
source share
2 answers

Include directive, which will transfer data between angularand vis. Any characteristic viscan be mimicked by angular, integrating visinto its cycle $digest.

DOM manipulation , vis.

, - , vis - , (, vis.event() vis API):

/* On directive link() function */

vis.event('bla-bla-bla', function (arg1, arg2, arg3) {
    scope.$evalAsync(function () {
        scope.emit('vis:bla-bla-bla', arg1, arg2, arg3);
    });
});

:

// On a parent controller where the directive is placed
//
// The $scope below can be $scope too,
// but it will traverse all child scopes first
$scope.$on('vis:bla-bla-bla', function ($event, arg1, arg2, arg3) {
    $event.stopPropagation(); // Useful, to avoid performance leak

    console.log($event, arg1, arg2, arg3);
});

1:

Plunkr, :

http://plnkr.co/edit/XlRkfazfYBmj0GM1PTeC?p=info

, vis-network, events , .

, , . !

+3

, , :

function actOnEvent($event){
     window.alert($event. ...);
};

$event - . , , , :

var vm = this;
vm.events = { click: actOnEvent};

html , ,

<vis-network data="vm.data" options="vm.options" events="vm.events"></vis-network>
0

All Articles