How to connect angular controllers using data from HTML code?
I have a server-side framework, which allows me to build an application by connecting components together. Some of these components get transformed into a bit of HTML markup. Other components only provide data for the first kind of komponents. Technical details of this part are not important.
Example: There are two components on the server VideoPlayer and PlayButton. The PlayButton is connected to VideoPlayer. When page is rendered, VideoPlayer become <div id="the_player" class="flowplayer">...</div>
and PlayButton become <button data-player-id="the_player">...</button>
. So the on-click handler of the button can use data-player-id
to lookup the player and make it play. VideoPlayer ID (the_player
) is passed between the components using connections on the server, so it is possible to have two players and multiple buttons, each button controlling only specified player. Notice that these connections are not specified in JavaScript code, so changing of component connections does not affect JavaScript code in any way.
Question: How to do such thing using Angular controllers? The Angular DI is too naive and expects only one instance of each kind of service. I like the two-way binding between controller and HTML DOM, it makes my widgets very simple. But how can I connect such widget to data source addressed in HTML attribute?