javascript - Angular Modal>Ctrl>Service>Ctrl inheritance not working -


I am trying to connect models to the services that allow me to update the global model in my app Although it does not seem to work as expected.

I have recently started appearing in AngularSS, so it is possible that I am misunderstood my code, but I believe that one service is an example of a factory singleton protest <$ P>

Model: {{language.title}

}

< Strong >>>> ctrl1: $ scope.language = langsrvic.store;

>>> srvic: langSrvic.store = myFactory;

>>> ctrl2: langSrvic.set ('Locale', 'FR');

>>> Language Instance Store Update (should reflect changes in controller 1 model)

  // application var app = angular Module ('app', []); // Controller 1 app.controller ('first', ['$ radius', 'language', function ($ radius, language) {$ scope.language = language.store; setTimeout (function () {console.log ($ Scope.language.title); // my application console.log (language.store.title); // some french}, 1500);}]); // language service, app.service ('language', ['i18n', function (i18n)) {return: location: 'n', store: i18n ['n'], set: function (prop, wall) {it [Prop] = val; This.store = i18n [this.locale];}}}]); // Factory - API temporarily app. Factory ('IILN', [Function () {Return instead of {{title: 'My app'}, F: {title: 'some thing French'}}}); // Controller 2 - Changing locale should update the frequency archive and before that scope app.controller ('second', ['$ scope', 'language', function ($ radius, language)] {language.set update Do ('locale', 'fr'); $ scope.language = language.store;}]);  
  & lt; Div ng-controller = "first" & gt; {{Language.title}} & lt; Div ng-controller = "second" & gt; {{Language.title}} & lt; / Div & gt; & Lt; / Div & gt;  

> Store refers to the object:

  set: function (prop, val) {this [prop] = val; This.store = i18n [this.locale]; // This line sets the language. Store on new object but controller is referring to old 1}  

View Bella for updates:


Comments