Does anyone know about this? Thanks. Will Huang於 2015年8月31日星期一 UTC+8上午2時18分53秒寫道: > > I feel confused about how angular.injector() get $injector component. As > I know, when calling to the *angular.injector(['ng', 'app']);* will get a > new *$injector* object which is different from the current running > Angular app's *$injector* object. > > I made a sample app over here: (Angular 1.3.14) > http://codepen.io/willh/pen/vNYYRm?editors=101 > > I'm trying to create a new *$injector* by using the *angular.injector()* > API. I'd like to get a brand new *$injector* in order to get "*version*" > service from *getVersion *function which is outside of the Angular app. > I was expected that controller shouldn't be run and shouldn't affect my > *version > *service object. I just wanna get the "*version*" service object only. > In my sample, the value for "*version*" service has a "*current*" > property and it's value is "*0.0.1*". As you can see, there is a > controller called "*MainCtrl*" that will change the version.current value > at *controller *initialization. When I calling to the *getVersion *function > outside of the Angular app and I created a new *$injector* object. In > that function, I expected that I should get "*0.0.1*" but it didn't. > I've got "*0.0.2*". I don't know why. Does anyone know? >
-- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
