javascript

  • factory(‘Scopes’, function ($rootScope) { var mem = {}; return { store: function (key, value) { $rootScope.$emit(‘scope.stored’, key); mem[key] = value; }, get: function (key) { return mem[key]; } }; });
  • controller(‘Ctrl2′, function($scope, $http, $state, Scopes) { if($scope.value=’something’){ alert(‘scope passed’); } });
  • Stack Overflow works best with JavaScript enabled
  • i tried using rootscope and passing values between controllers
  • using just factory to store data and fetch worked like a charm.

Factories don’t have access to the current controller/directive scope
because there isn’t one. They do have access to the root of the
application though and that’s why $rootScope is available

@soiqbot: How to get data dynamically from one controller to another in angularjs?

#javascript #angularjs #controller

Did more people use the DC Metro transit system on the day of Trump’s inauguration than on the day of Obama’s second inauguration (in 2013)?

Can a ground plane be used as a current return path? (DC only, no signals, no AC)

What is the best way to say “gentle reminder” in German?

javascript

You might also like More from author

Comments are closed, but trackbacks and pingbacks are open.