1

I want to create a transclude directive using this HTML :

%h2 Widgets :
.row-fluid{ "ng-controller" => "ApplicationDashboardCtrl" }
  .span6
    %widget{ type: "chart", "ng-model" => "widget", "ng-repeat" => "widget in widgets","ng-transclude" => "" }
      .chart.bottom20
        {{ widget.title }}

      %data-source{ src: "/public/test.json"}
      %lines{ y: "value", x: "label" }

  .span6

The issue is, my two directives does not share the same scope instance. I created a plinkr to represent my issue :

My issue using Plnkr

I do not understand why my two directives does not share the same scope and why my "widget" directive does not catch the event "setupExtra". I know, I can use the $rootScope but I wanted to do without it.

Any idea?

1 Answer 1

3

I found my solution, I have to use $emit instead of $broadcast

  • $broadcast -- dispatches the event downwards to all child scopes,
  • $emit -- dispatches the event upwards through the scope hierarchy.

Sorry for question, I keep it for other beginners :)

Sign up to request clarification or add additional context in comments.

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.