Link to home
Create AccountLog in
Avatar of MrChrisDavids
MrChrisDavids

asked on

Connect two scopes in AngularJS - kind of

So I'm just starting out with AngularJS and I've got two scopes defined in a controller. In the view I want to have a sort of lookup to the second scope. How's that done?

So more or less - the variable at..

<div class="panel-note">{{ servers.install_id }}</div>

Open in new window

needs to be replaced with {{ notes.installation }} where notes.id = servers.install_id

I hope it makes sense?
Avatar of Kyle Hamilton
Kyle Hamilton
Flag of United States of America image

not sure how you can have two scopes in one controller.  a controller has one scope - that's kind of a basic premise of angular. there are situations where you might end up with some nested scopes within your app, but you would never "define" two scopes in the controller

it's not clear what you are trying to acheive.

can you explain on a higher level what the requirement is, and/or, provide a plunker or jsfiddle with the code in question
ASKER CERTIFIED SOLUTION
Avatar of ambience
ambience
Flag of Pakistan image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of MrChrisDavids
MrChrisDavids

ASKER

Indeed it's two variables in a scope - nothing else. Sorry about the mixup there.

I have a dynamic list of servers shown as panels on a view. There are some details on these servers that are common for certain sets and those are the ones that I'd like to render on the view

The details are however accessed from another datasource and the only matches are some IDs from the servers panel that can be matched if they're valid for detail_x kind of.

Let's say, for instance - 20 servers are used for application XYZ which is identified by ID 1. All servers come in with a variable servers.app_id = 1 and I'd then like to write out "XYZ" on the panel instead of the ID.

There's plenty of different IDs that would be replaced, not just the app and notes.

I'll have a look at a directive - see if I can get that working. Thanks!