tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/181-model-is-null-when-i-try-and-use-it-later-in-the-serviceRobotlegs: Discussion 2018-10-18T16:35:18Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/32174382010-10-04T17:14:40Z2010-10-04T17:14:40ZModel is null when I try and use it later in the service<div><p>Hi Nikos,</p>
<p>Injected values have to be public - yours is private :)</p>
<p>An easy mistake to make, and an easy fix too!</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/32174382010-10-04T17:27:15Z2010-10-04T17:27:15ZModel is null when I try and use it later in the service<div><p>After doing what Stray said, you'll have to fix the [Inject] tag too :)<br />
<strong>Wrong:</strong></p>
<p>[inject]</p>
<p>[InJect]</p>
<p>[INJECT]</p>
<p><strong>Right:</strong></p>
<p>[Inject]</p>
<p>public var someClass:SomeClass;</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/32174382010-10-04T17:33:57Z2010-10-04T17:33:57ZModel is null when I try and use it later in the service<div><p>Well spotted! I was so distracted by the private I didn't even check the spelling of [Inject].</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/32174382010-10-05T08:25:49Z2010-10-05T08:25:49ZModel is null when I try and use it later in the service<div><p>haha woops, btw why is it that vars need to be public?</p></div>Nikos tag:robotlegs.tenderapp.com,2009-10-18:Comment/32174382010-10-05T08:31:03Z2010-10-05T08:31:03ZModel is null when I try and use it later in the service<div><p>Just because if they were private the injector wouldn't be able to access them. The actual method of setting values is subject to the same rules as usual.</p>
<p>The alternative is setter injection - private var, and a public setter func, marked with inject.</p></div>Stray