Skip to content

Instantly share code, notes, and snippets.

@sunkay
Created April 25, 2013 02:53
Show Gist options
  • Select an option

  • Save sunkay/5457190 to your computer and use it in GitHub Desktop.

Select an option

Save sunkay/5457190 to your computer and use it in GitHub Desktop.
Angularjs forms controllers, using a shared service & using $location to redirect to our desired path
function addDeviceController($scope, $location, Devices)
{
//console.log("add-Field" + $scope.device.name);
$scope.add = function(device){
device['id'] = (Devices.query().length)+1;
Devices.add(device);
console.log(device);
// redirect to main screen
$location.path('#/');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment