Wednesday 15 April 2015

angularjs - How to properly include global variables and update them in Angular JS? -


Let's say there is a variable "global fert" in my app that keeps track of all the "fruits" within my app .

Various global benefits = {}

global fruit ['pear'] = {name: 'pear', color: 'green'}; Global Fert ['Apple'] = {Name: 'Apple', Color: 'Blue'};

How should this global variable be included in my fingerprints application, like I can get directions or scopes which can call it and check it on its status? Or is not it the way of the finger?

You can define your module: ap.value (' Global Fert ', {Pears: {name:' pear ', color:' green '}, apple: {name:' apple, 'color:' blue '});

Then, when you want to work with it, you can inject this value:

  app.controller ('MyController', [ '$ Scope', 'global fert', function ($ scope, global difference) {$ scope.globalFruits = globalFruits;}];    

No comments:

Post a Comment