how can i tell angular to inject the data from scope.shits into ShitDetail Controller?
function ShitCtrl($scope) {
$scope.shits = [
{
"id": "goMedus",
"name": "goMedus",
"snippet": "Fast just got faster with Nexus S.",
"copy": "hallo"
},
and here is the data injecton in the tutorial done via json. i would like to get oscar mike without because i have troubles in connecting to external json with grails urlMappings, so i would like to do this later on. any help appreciated
function ShitDetailCtrl($scope, $routeParams) {
$scope.shitId = $routeParams.shitId;
}
my view looks like so:
TBD: detail view for {{shitId}} and {{shitName}}
shitId gets rendered and shitName not.
You cannot inject a data from a scope controller to another controller.
But you have three solutions to share data between controllers:
Define your variable into the root scope. Since every scope inherits from the root scope, your data will be available to all of your controllers.
Use events to send data to other controller (use $broadcast and $on functions to send/catch events).
Use a dedicated service that will be used to share data between your controllers.