Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I am using UI Bootstrap's typeahead directive, and added my own popup template via typeahead-popup-template-url. In that template, I'd like to access scope variables from the parent template (i.e. the one in which I've used the typeahead directive). Is this possible?

Here's a (broken) example of what I'm trying to do ("hello" should be present in the dropdown): http://plnkr.co/edit/ITT1SdRfUWeeN6n3aMqu?p=preview

I'd like to do this WITHOUT modifying the typeahead directive. I don't want to muck around in third party (uib) code if there's a more elegant solution.

share|improve this question
up vote 0 down vote accepted

In your template, you need to reference the $parent scope. Change:

This should say "hello": {{hello}}</h1>

To:

This should say "hello": {{$parent.hello}}</h1>
share|improve this answer
    
Thanks! I was hoping there'd be a simple solution. – lakenen 2 days ago

Bootstrap, jquery ui, kendoui, yui etc Isn't that a bit much of frameworks together O.o

Anyway this post might help: How to access parent scope from within a custom directive *with own scope* in AngularJS?

share|improve this answer
    
Correct me if I'm wrong, but it seems like this would require modifying the uib directive code? See my question for clarification. Thanks! – lakenen Jan 10 at 1:17
    
Maybe write a custom directive besides the original based on the original? Not too much experience with angular to know if that is possible and a good idea though. – seahorsepip Jan 10 at 1:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.