angularjs - Why do I get undefined for this Angular scope? -


i use factory create objects particular module

angular.module("mymodule").factory('myentity', .... 

and module accepts generated 'myentity' injected dependency:

angular.module("mymodule").controller('myproductctrl', [ '$scope', 'myentity', '$rootscope', 'myapiservice'  ... 

the module has following subscriber function used subscribe entity inside module this:

    myentity.subscribe(function(otherentity) {          $scope.myreference = otherentity;      }); 

at runtime, above $scope.myreference assigned expected object it's value when first module loaded

... , i've added function onto scope inside same module:

    $scope.mymodulefunction = function (product) {         if (myreference.yadda) {             ...         }     } 

... above '$scope' undefined @ point function called via directive (in fact it's undefined once web page has been displayed). why might case?


Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -