{"action":"created","issue":{"url":"https://api.github.com/repos/CodeAdventure/space-ui/issues/24","labels_url":"https://api.github.com/repos/CodeAdventure/space-ui/issues/24/labels{/name}","comments_url":"https://api.github.com/repos/CodeAdventure/space-ui/issues/24/comments","events_url":"https://api.github.com/repos/CodeAdventure/space-ui/issues/24/events","html_url":"https://github.com/CodeAdventure/space-ui/issues/24","id":64824590,"number":24,"title":"Routes only work in namespace","user":{"login":"zimt28","id":1764689,"avatar_url":"https://avatars.githubusercontent.com/u/1764689?v=3","gravatar_id":"","url":"https://api.github.com/users/zimt28","html_url":"https://github.com/zimt28","followers_url":"https://api.github.com/users/zimt28/followers","following_url":"https://api.github.com/users/zimt28/following{/other_user}","gists_url":"https://api.github.com/users/zimt28/gists{/gist_id}","starred_url":"https://api.github.com/users/zimt28/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zimt28/subscriptions","organizations_url":"https://api.github.com/users/zimt28/orgs","repos_url":"https://api.github.com/users/zimt28/repos","events_url":"https://api.github.com/users/zimt28/events{/privacy}","received_events_url":"https://api.github.com/users/zimt28/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-03-27T18:31:45Z","updated_at":"2015-03-28T11:39:21Z","closed_at":null,"body":"Hey there :)\r\n\r\nI'm still using space-ui@3.4.4 or so, I hope you still remember how that version worked ;)\r\nI want to move my app into packages as I think I will get a better structure then. I will not have my global `App` namespace anymore then, so before doing that, I tried to remove it.\r\n\r\nAll I did was changing this\r\n```coffee\r\n@injector.map('PatientsNewController').toSingleton App.PatientsNewController\r\n# to\r\n@injector.map('PatientsNewController').toSingleton PatientsNewController\r\n```\r\n\r\nand \r\n\r\n```coffee\r\nclass App.PatientsNewController\r\n# to\r\nclass @PatientsNewController\r\n```\r\n\r\nI don't know why, but it just stopped working. I get my \"not found\" page, and the url changes to `undefined`. Do you have an idea what might be wrong?\r\n\r\nI can access `PatientsIndexController` from the console and when I log it before mapping it, I can get it there, too. Really strange :)"},"comment":{"url":"https://api.github.com/repos/CodeAdventure/space-ui/issues/comments/87213400","html_url":"https://github.com/CodeAdventure/space-ui/issues/24#issuecomment-87213400","issue_url":"https://api.github.com/repos/CodeAdventure/space-ui/issues/24","id":87213400,"user":{"login":"DominikGuzei","id":172414,"avatar_url":"https://avatars.githubusercontent.com/u/172414?v=3","gravatar_id":"","url":"https://api.github.com/users/DominikGuzei","html_url":"https://github.com/DominikGuzei","followers_url":"https://api.github.com/users/DominikGuzei/followers","following_url":"https://api.github.com/users/DominikGuzei/following{/other_user}","gists_url":"https://api.github.com/users/DominikGuzei/gists{/gist_id}","starred_url":"https://api.github.com/users/DominikGuzei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DominikGuzei/subscriptions","organizations_url":"https://api.github.com/users/DominikGuzei/orgs","repos_url":"https://api.github.com/users/DominikGuzei/repos","events_url":"https://api.github.com/users/DominikGuzei/events{/privacy}","received_events_url":"https://api.github.com/users/DominikGuzei/received_events","type":"User","site_admin":false},"created_at":"2015-03-28T11:39:21Z","updated_at":"2015-03-28T11:39:21Z","body":"Hey @zimt28, when you start splitting up your application into packages (which i highly recommend) then you can start using a `Space.Module` for each package which publishes itself into the global Space environment where it can be required by the main `Space.Application`. Here is some example code:\r\n\r\n```coffeescript\r\nSpace.Module.extend(function() {\r\n      this.publish(this, 'FirstModule'); # publishes this module into global space environment\r\n      return {\r\n        configure: function() {\r\n          this.injector.map('testValue').toStaticValue(testValue); # application injector\r\n        }\r\n      }\r\n    });\r\n\r\n    Space.Application.create({\r\n      RequiredModules: ['FirstModule'], # require your modules which might live in packages\r\n      Dependencies: { testValue: 'testValue' }, # you can also use mapped values from modules\r\n      configure: function () { testResult = this.testValue; }\r\n    });\r\n```\r\n\r\nThis topic is actually not really related to `space:ui` as the dependency injection and application infrastructure comes from the package [space:base](https://github.com/CodeAdventure/meteor-space) and you can read through [the integration tests](https://github.com/CodeAdventure/meteor-space/tree/master/tests/integration) to get a rough feeling how applications and modules work together.\r\n\r\nLong story short: `Space.Application` extends `Space.Module` and has a very similar api. The biggest difference is: There is only a single `Space.Application` in your app with a single `Space.Injector` instance that is automatically shared with all required modules. So you can map dependencies within your modules like you did in your application before and access them from anywhere. One way to organize the dependencies is to namespace them based on the package name, e.g: `@injector.map('MyModule.AwesomeServiceClass').asSingleton()`"}}