0

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.

1 Answer 1

2

You cannot inject a data from a scope controller to another controller.

But you have three solutions to share data between controllers:

  1. 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.

  2. Use events to send data to other controller (use $broadcast and $on functions to send/catch events).

  3. Use a dedicated service that will be used to share data between your controllers.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.