Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8783873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:56:20+00:00 2026-06-13T20:56:20+00:00

I have a directive that looks like this: app.directive(‘fieldsetCollapse’, function() { return { restrict:

  • 0

I have a directive that looks like this:

app.directive('fieldsetCollapse', function() {
return {
    restrict: 'A',
    scope: {},
    compile: function(tElement, tAttrs, transclude) {
        var wrapperElement = angular.element('<div ng-show="isOpen"></div>'),
            legendElement = tElement.find('legend'),
            collapsibleContent = tElement.children().not('legend'),
            toggleBtn = angular.element('<a href="#" class="twisty" ng-class="{ true: \'twisty-open\', false: \'twisty-closed\' }[isOpen]" ng-click="toggle()"></a>');

        legendElement.css('cursor', 'pointer')
                      .attr('ng-click', 'toggle()');

        tElement.css({
            'position': 'relative',
            'marginLeft': '20px'
        });
        tElement.prepend(toggleBtn);

        angular.forEach(collapsibleContent, function(obj, i) {
            $(obj).remove();
            wrapperElement.append(obj);
        });

        tElement.append(wrapperElement);

        return function(scope, element, attrs) {
            var directiveValue = (scope.$eval(attrs.gaigCollapsibleFieldset));
            scope.isOpen = (directiveValue == undefined) ? true : directiveValue;

            scope.toggle = function() {
                scope.isOpen = !scope.isOpen;
            }

        }
    }
}

});

Which works with this markup:

<fieldset fieldset-collapse> ... </fieldset>

If I try adding anything inside <fieldset> such as this:

<fieldset fieldset-collapse>{{foo}}</fieldset>

…where foo is defined on the scope of my controller, the output is

{{foo}}

Angular isn’t compiling anything I add between my tag with the directive. Am I missing something to make this happen inside my directive?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:56:22+00:00Added an answer on June 13, 2026 at 8:56 pm

    You are creating an isolated scope in the directive definition object

    return {
        restrict: 'A',
        scope: {} // <--- isolated scope
    }
    

    This means that your directive doesn’t have access to the parent scope where the value of foo resides.

    Just comment it out.
    Example http://jsfiddle.net/jaimem/RE7Jj/1/

    If you don’t want the directive to have full access to the parent scope you can set bidirectional binding between a local scope property foo and the parent’s foo. More details in the docs: http://docs.angularjs.org/guide/directive

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a layout that looks like this: (without the arrows) the pictures of
I have a chat on a web site that looks like this. I am
I have some code that looks like this (I left out the parts that
I have an app that I'd like the swipe gesture to flip to a
So, given that I have some type of data structure like this within a
I have an aspx page that has a @Page directive which points to a
I have an IDL file that has a #pragma prefix directive, but whenever I
I have a little app that runs fine on local dev appengine, but appengine
I currently have a simple iPhone app that loads a custom subclass of UIView.
Basically, I want to have an app with only one view that has an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.