Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
How can I modify angularjs transcluded element?

I have parent-directive and child-directive. I'm using ng-transculde.

<parent-directive>
    <child-directive type="SOME_TYPE" 
                     class="child"
                     options="{fooId: vm.fooId, fooType: vm.fooType}">
    </child-directive>
</parent-directive>

I want to set child-directive "id" from parent directive. Now I'm trying to do like this:

.directive('parentDirective', function ($rootScope, fileService) {
        return {
            transclude: true,
            restrict: 'E',
            scope: {
                disabled: "=?"
            },
            link: function (scope, element, attrs) {
                document.getElementById('transcluded_content').firstElementChild.id = 'myId'
            },
            template: '<div><ng-transclude id="transcluded_content"></ng-transclude></div>'
        };
    })

It shows error TypeError: Cannot set properties of null (setting 'id') I tried many ways and everytime it shows errors. I think I don't understand logic or I don't know method to use. Please help me...

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!