Often that happens that we refer to the same data from different components. We need those components to update whenever that data change. That is easy to achieve with ngBackbone. We can instantiate a model or collection and pass the reference to all the corresponding components. For instance we can take the example from Nesting Components and change our foo.ts and bar.ts to build a list of worlds from collections named worlds:
foo.ts
import { Component, View } from"ng-backbone";@Component({ el:"ng-foo", template:`Hello, it's Foo <dl><dt data-ng-for="let world of worlds" data-ng-text="world.name"></dt></dl>`})exportclassFooViewextendsView {initialize(){this.render(); }}
The collection itself we create in app.ts and pass it to AppView and both FooView and BarView with view options: