tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/254-model-queryRobotlegs: Discussion 2012-03-05T11:43:53Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/26298472010-08-19T11:37:09Z2010-08-19T11:37:09ZModel Query<div><p>Hey Scott,</p>
<p>A short and quick way to do this is in your context,</p>
<p><code>injector.mapSingleton(UserPreferencesModel);</code></p>
<p>Then you can inject this model into your service and the service can then populate the model, the injector will create a single instance of the model, and anywhere you ask for it the injector will supply that same instance.</p>
<p>So, after you populated the model, it is now available for injection into your mediators.</p>
<p>Hope this helps.</p>
<p>Thanks,<br />
Jason</p></div>Jason Diastag:robotlegs.tenderapp.com,2009-10-18:Comment/26298472010-08-19T11:55:58Z2010-09-03T10:19:18ZModel Query<div><p>Hi Jason,</p>
<p>I didn't realise you could inject the model into the service, so this would solve it.</p>
<p>Thanks for the help, appreciated.</p>
<p>Scott<br />
</p></div>darloScottttag:robotlegs.tenderapp.com,2009-10-18:Comment/26298472010-08-19T12:01:49Z2010-08-19T12:01:49ZModel Query<div><p>As long as you let the injector create all your objects, you can inject anything anywhere - that's what makes DI fun!</p></div>Shaun Smith