0

Here's a plnkr.

How do I access the headerInput model from within the sideMenuContent directive? Let's say I have 10 other ng-models in sideMenuHeader directive that I want to access in sideMenuContent, is there any way of making it easily scalable?

1 Answer 1

1

You need to use the dot notation for objects. See Understanding Scopes in AngularJs

So instead of headerInput, use something like menu.headerInput and also make sure to initialize a menu object in your controller like so $scope.menu = {}; (or you can also set default values).

I updated your plunkr to show you how it works

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

3 Comments

Sweet, this works! It feels a tad ugly though (my fault). What do you think about all of my ng-transclude's and stuff? I tried to create a boilerplate sideMenu-directive with sub-directives (header and content). Is there a better way of doing what I've tried to do?
I don't think that it's ugly, you are using ng-transclude for their intended functionality. The only suggestion I would make is to not have your template all on one line or to separate it out into a templateURL so that it is easier to read.
Yeah I hate writing HTML as strings in JS, no matter the length of it. I did so on my plnkr because i was lazy :).

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.