{"action":"created","issue":{"url":"https://api.github.com/repos/ga-wdi-exercises/project3/issues/136","repository_url":"https://api.github.com/repos/ga-wdi-exercises/project3","labels_url":"https://api.github.com/repos/ga-wdi-exercises/project3/issues/136/labels{/name}","comments_url":"https://api.github.com/repos/ga-wdi-exercises/project3/issues/136/comments","events_url":"https://api.github.com/repos/ga-wdi-exercises/project3/issues/136/events","html_url":"https://github.com/ga-wdi-exercises/project3/issues/136","id":145732703,"number":136,"title":"Pushing data to json","user":{"login":"jeffreyeaton76","id":15959851,"avatar_url":"https://avatars.githubusercontent.com/u/15959851?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffreyeaton76","html_url":"https://github.com/jeffreyeaton76","followers_url":"https://api.github.com/users/jeffreyeaton76/followers","following_url":"https://api.github.com/users/jeffreyeaton76/following{/other_user}","gists_url":"https://api.github.com/users/jeffreyeaton76/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffreyeaton76/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffreyeaton76/subscriptions","organizations_url":"https://api.github.com/users/jeffreyeaton76/orgs","repos_url":"https://api.github.com/users/jeffreyeaton76/repos","events_url":"https://api.github.com/users/jeffreyeaton76/events{/privacy}","received_events_url":"https://api.github.com/users/jeffreyeaton76/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-04-04T16:19:05Z","updated_at":"2016-04-04T16:23:57Z","closed_at":null,"body":"We're having a little trouble getting this form to add data to our remote json. For a little while we got a POST 400 error but now it's stopped talking to the server at all (hitting Submit causes no reaction in the rails server). \r\n\r\nHere is our factory which communicates with the other server:\r\n```\r\n  function cityFactoryFunction($resource){\r\n    return $resource(\"http://localhost:3000/cities/:id.json\", {}, {\r\n      update: {method: \"PUT\"}\r\n    });\r\n  }\r\n```\r\nand here is the function for the form:\r\n```\r\n  function cityFormFunction(CityFactory){\r\n    var vm = this;\r\n    vm.newCity = new CityFactory();\r\n    return{\r\n      templateUrl: \"city.form.html\",\r\n      scope: {\r\n        city: \"=\",\r\n        formMethod: \"@\"\r\n      },\r\n      link: function(scope){\r\n        scope.create = function(){\r\n          CityFactory.save(vm.newCity, function(response){\r\n            console.log(\"hi!\");\r\n            response.lat = parseFloat(response.lat);\r\n            response.long = parseFloat(response.long);\r\n            CityFactory.push(response);\r\n          });\r\n        };\r\n      }\r\n    }\r\n  }\r\n```\r\nand here is the form itself:\r\n```\r\n<input type=\"text\" data-ng-model=\"vm.newCity.name\" />\r\n<label for=\"name\">City</label>\r\n\r\n<input type=\"text\" data-ng-model=\"vm.newCity.desc\" />\r\n<label for=\"desc\">Description</label>\r\n\r\n<input type=\"text\" data-ng-model=\"vm.newCity.lat\" />\r\n<label for=\"lat\">Latitude</label>\r\n\r\n<input type=\"text\" data-ng-model=\"vm.newCity.long\" />\r\n<label for=\"long\">Longitude</label>\r\n\r\n<button type=\"button\" data-ng-click=\"vm.create()\">Submit</button>\r\n```"},"comment":{"url":"https://api.github.com/repos/ga-wdi-exercises/project3/issues/comments/205375435","html_url":"https://github.com/ga-wdi-exercises/project3/issues/136#issuecomment-205375435","issue_url":"https://api.github.com/repos/ga-wdi-exercises/project3/issues/136","id":205375435,"user":{"login":"RobertAKARobin","id":6268177,"avatar_url":"https://avatars.githubusercontent.com/u/6268177?v=3","gravatar_id":"","url":"https://api.github.com/users/RobertAKARobin","html_url":"https://github.com/RobertAKARobin","followers_url":"https://api.github.com/users/RobertAKARobin/followers","following_url":"https://api.github.com/users/RobertAKARobin/following{/other_user}","gists_url":"https://api.github.com/users/RobertAKARobin/gists{/gist_id}","starred_url":"https://api.github.com/users/RobertAKARobin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RobertAKARobin/subscriptions","organizations_url":"https://api.github.com/users/RobertAKARobin/orgs","repos_url":"https://api.github.com/users/RobertAKARobin/repos","events_url":"https://api.github.com/users/RobertAKARobin/events{/privacy}","received_events_url":"https://api.github.com/users/RobertAKARobin/received_events","type":"User","site_admin":false},"created_at":"2016-04-04T16:23:57Z","updated_at":"2016-04-04T16:23:57Z","body":"Ah. That's because you have `vm.create()`. `vm` refers to the controller. Anything you attach to `scope` inside your directive can be accessed without a `something.`, e.g. just `data-ng-click=\"create()\"`\r\n\r\n`¯\\_(ツ)_/¯`"}}