0

I have main template with a search box in the navigation bar.

I want to bind the search box to a variable in the view's scope.

How do I do that?

4
  • Can you explain it in more details? Commented Dec 19, 2014 at 14:27
  • I have a search box in the navigation bar at the top - just like this stackoverflow page. Imagine that the part below the black navigation bar is the view. The view has its own scope. I wan't to bind the search box to a variable in the view's scope. Since search box is in the parent template, the usual method of binding only binds to variables in the same scope as the html element. Commented Dec 19, 2014 at 14:32
  • use $parent.viewname.. Commented Dec 19, 2014 at 14:39
  • i mean inside ng-model, use '$parent.' . Commented Dec 19, 2014 at 14:40

1 Answer 1

1

If your child scope inherits from parent it will have access to parent's variables. Have a look at the working example jsfiddle where updating parent's ng-model='user.name' is visible in child scope.

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

1 Comment

I am using views. But it works with views too. Thanks for the JSFiddle.

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.