1

:) I have a input in the body of my index.html file Which acts like a static header to my templates. The only problem is that i have the filter in my template like so:

<!-- Home Template --> <script id="home.html" type="text/ng-template"> <ion-view title="plz help"> <ion-content> <div class="list" id="list" ng-repeat="phone in phones | filter:query"> ... </div> </ion-content> </ion-view> </script>

So that makes it "2 separate files" (they are both inside index.html). This makes it so that i can't for example "clear the filter" from a button in my header that's outside of the template.

Is there any way I can "include" the different "files" in each other so that i can execute JavaScript in in both "files"?

Thanks in advance!

1 Answer 1

1

You can do this with a nested scope. Because query live in root scope, is visible from scope of your controller. You have exemple here

But, sometimes there is a problem that variable from root or parent scope is not visible in nested scope if previously is not defined in main controller. Also, you can use $rootScope service to easier access.

Hope to I clarified a little.

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

1 Comment

Thank you! you make it look so easy! :L Thanks for an obvious and great answer mate!! :)

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.