5

This example works well with AngularJS 1.1.5 (it's going to append it into div), but with 1.2.5 not (it's leaves html content without append).

https://egghead.io/lessons/angularjs-transclusion-basics

app.directive("panel", function() {
    return {
        restrict: "E",
        transclude: true,
        template: '<div class="panel" ng-transclude>This is a panel component</div>'
    }
})

AngularJS 1.1.5: http://plnkr.co/edit/BLe56D9YZxSIAiJ31wW0 ("This is..." appears as expected) AngularJS 1.2.5: http://plnkr.co/edit/h6dUrXXXBOQUtzsJqT4S ("This is..." doesn't appears)

In 1.1.5 "transclude: true" works as expected (text is appended to panel), but in > 1.2.0 not.

Any help?

1
  • In Angular v1.3.15 ng-transclude still doesn't work, but in 1.1.5 it works. Commented Apr 9, 2015 at 6:54

2 Answers 2

5

Change your template in the directive to:

template: '<div class="panel" >This is a panel component</div><div ng-transclude></div>'
Sign up to request clarification or add additional context in comments.

Comments

0

In fact, the exact behavior is now captured like so:

template: '<div class="panel"> This is a panel component <div ng-transclude></div></div> '

i.e. If you want the button in the panel, and the panel text also showing in the panel.

btw., I dont know yet why.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.