angular1.6

Angular 1.6 & multiple modules: sharing global variable between modules & components

你说的曾经没有我的故事 提交于 2019-12-11 11:34:05
问题 I'm using Angular 1.6.7. I have created multiple modules in my app. How can I pass a constant (e.g. "rootURL") defined in a parent module (myApp) to a child module (childApp)? More specifically, I need to assign the value of "rootURL" to the templateUrl of childApp's component so we don't have to hard code the root directory for every module. I think I know how to share variables inside a controller, but don't know how to do that inside the definition of a component. Here's a Plunker to demo.

how to access this inside an event receiver angular

会有一股神秘感。 提交于 2019-12-08 03:45:06
问题 I was going over this tutorial to implement sending/receiving broadcast messages in my angular 1.5 app. so inside a controller I have this: update(){ this.$rootScope.$broadcast('language_changed'); } and in another controller I got this: $rootScope.$on('language_changed', function (event, data){ this.updateStore(); <--- this here is undefined }); } updateStore() { this.store = { .. language_id: this.LanguageService.get(), } } I'm wondering how can I get hold of this inside the broadcast. This