in

Passing object reference to Angular JS directive


I am trying to pass an object reference (or a copy) as an attribute to my custom directive inside a loop. I cannot seem to make this work without the variable being on the controller scope.

`function decode() {

        var html="";

        for(var element of $scope.currentPage.elements) {
            
            html += `<pv-${element.type} id="${element.id}" element="element"></pv-${element.type}>`;
        }
        
        var j = $(html);  // Compile will not work unless the same var is used in statements below!
        $('#viewer').html(j);
        $compile(j)($scope);
    }`

I need the element counter variable sent to the directive. How can I do this without creating a bunch of different variables on my controllers scope?



Source: https://stackoverflow.com/questions/70609693/passing-object-reference-to-angular-js-directive

Project for Student Management System and use of CURD Operation

Details,PoC and patches for CVE-2021-45383 & CVE-2021-45384