{"action":"created","issue":{"url":"https://api.github.com/repos/zurb/front-router/issues/1","labels_url":"https://api.github.com/repos/zurb/front-router/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/zurb/front-router/issues/1/comments","events_url":"https://api.github.com/repos/zurb/front-router/issues/1/events","html_url":"https://github.com/zurb/front-router/issues/1","id":91327836,"number":1,"title":"Adding custom data to front router","user":{"login":"Dillie-O","id":991466,"avatar_url":"https://avatars.githubusercontent.com/u/991466?v=3","gravatar_id":"","url":"https://api.github.com/users/Dillie-O","html_url":"https://github.com/Dillie-O","followers_url":"https://api.github.com/users/Dillie-O/followers","following_url":"https://api.github.com/users/Dillie-O/following{/other_user}","gists_url":"https://api.github.com/users/Dillie-O/gists{/gist_id}","starred_url":"https://api.github.com/users/Dillie-O/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dillie-O/subscriptions","organizations_url":"https://api.github.com/users/Dillie-O/orgs","repos_url":"https://api.github.com/users/Dillie-O/repos","events_url":"https://api.github.com/users/Dillie-O/events{/privacy}","received_events_url":"https://api.github.com/users/Dillie-O/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-06-26T18:28:55Z","updated_at":"2015-08-19T17:24:32Z","closed_at":null,"body":"When Z4A was using front-matter, I was able to achieve a nifty effect of dynamically updating my page titles in a shared header section. Here's how it worked:\r\n\r\nIn my page templates, I had the following front-matter definition:\r\n\r\n    ---\r\n    name: AddPrayer\r\n    url: /prayers/add\r\n    controller: PrayersController\r\n    data:\r\n        title: Add Prayer\r\n    ---\r\n\r\nArmed with this data, I used a route changing trick in the run function to pull this data and update things accordingly:\r\n\r\n    function run($rootScope) {\r\n      \tFastClick.attach(document.body);\r\n\r\n  \t$rootScope.$on('$routeChangeSuccess', function (event, current, previous) {\r\n  \t\t$rootScope.title = current.$$route.data.vars.data.title;\r\n  \t});\r\n\r\n  \t$rootScope.$on('$stateChangeStart',\r\n\t\tfunction (event, toState, toParams, fromState, fromParams) {\r\n\t\t\t$rootScope.title = toState.data.vars.data.title;\r\n\t});\r\n    }\r\n\r\nThis was made possible due to what front-matter provided. You probably know more about angular than I do, but we have to register both of those events (routeChange and stateChage) so that you can track either when a view is directly loaded (page link or refresh) vs an action through the app. Granted rootScope has it's own concerns, but hey, it was cool. I was also using this to update metadata stuff in the head of the page.\r\n\r\nIt would be nice if we could add something like this to front-router I'm sure there is additional use cases for custom data, and this doesn't seem too hard to work with, at least in my mind.\r\n\r\nLet me know your thoughts.\r\n\r\nThanks for all you hard work!"},"comment":{"url":"https://api.github.com/repos/zurb/front-router/issues/comments/132703016","html_url":"https://github.com/zurb/front-router/issues/1#issuecomment-132703016","issue_url":"https://api.github.com/repos/zurb/front-router/issues/1","id":132703016,"user":{"login":"Dillie-O","id":991466,"avatar_url":"https://avatars.githubusercontent.com/u/991466?v=3","gravatar_id":"","url":"https://api.github.com/users/Dillie-O","html_url":"https://github.com/Dillie-O","followers_url":"https://api.github.com/users/Dillie-O/followers","following_url":"https://api.github.com/users/Dillie-O/following{/other_user}","gists_url":"https://api.github.com/users/Dillie-O/gists{/gist_id}","starred_url":"https://api.github.com/users/Dillie-O/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dillie-O/subscriptions","organizations_url":"https://api.github.com/users/Dillie-O/orgs","repos_url":"https://api.github.com/users/Dillie-O/repos","events_url":"https://api.github.com/users/Dillie-O/events{/privacy}","received_events_url":"https://api.github.com/users/Dillie-O/received_events","type":"User","site_admin":false},"created_at":"2015-08-19T17:24:32Z","updated_at":"2015-08-19T17:24:32Z","body":"I can see two options...\r\n\r\n1 - Just let the YAML read anything and treat things that aren't reserved words as custom variable names. That means that they easily show up in $state.current.data.XXX\r\n\r\n2 - Have an extra field called \"custom\" or something like that which will be the array for the custom data we want to put there. That might be a little nicer since it conforms to existing front-matter layouts, and I don't mind having to go \"one level\" deeper to access my custom data. \r\n\r\nI think that would make it simple to access and work with. Thoughts?"}}