eventemitter

EventEmitter in shared service's constructor doens't emit data

♀尐吖头ヾ 提交于 2020-01-02 09:53:34
问题 I have a HomeCmp and Shared Service . Look at the shared service 's constructor. I have manually set 'Guest' string and trying to emit UserModel object . But it doesn't receive object in HomeCmp 's ngOnInit . If you click the button, it will work. any suggestion? How can I show Guest string when I run the app through EventEmitter . service.ts import {EventEmitter} from 'angular2/core'; import {UserModel} from 'app/models'; export class NavService { user:EventEmitter<UserModel>=new

EventEmitter in shared service's constructor doens't emit data

一个人想着一个人 提交于 2020-01-02 09:53:34
问题 I have a HomeCmp and Shared Service . Look at the shared service 's constructor. I have manually set 'Guest' string and trying to emit UserModel object . But it doesn't receive object in HomeCmp 's ngOnInit . If you click the button, it will work. any suggestion? How can I show Guest string when I run the app through EventEmitter . service.ts import {EventEmitter} from 'angular2/core'; import {UserModel} from 'app/models'; export class NavService { user:EventEmitter<UserModel>=new

Using @Output hide to some child component

拥有回忆 提交于 2019-12-25 09:35:20
问题 My issue is I would replace/hide some child components (Child1, 2 and 3) by a "subchild component" each time the toggleSubChild() function is called using @Output decorator (it's just an idea, maybe there's better way to do that); So each time the subChild is called then it delete the Child1, 2 and 3 from the parent component using the EventEmitter value open/close. So the hierarchy is Parent ==> Child1 2 and 3 ==> SubChild I hope I'm clear enough..if not feel free to ask..thanks in advance

Node event emitter in other modules

百般思念 提交于 2019-12-24 11:44:07
问题 I have 3 different javascript files, the smallest one is emitting an event, meanwhile the second (bigger one) file picks up the event and sends it further to the main file. This is what I have tried so far: //mini.js var EventEmitter = require('events').EventEmitter; var ee = new EventEmitter; console.log("Emitting event"); var message = "Hello world"; ee.emit('testing',message); //second.js var mini = require('./mini.js'); var EventEmitter = require('events').EventEmitter; var ee = new

Node.js EventEmitter `on` event is not responding to `emit` actions

早过忘川 提交于 2019-12-24 11:20:09
问题 I have a Node.js app that represents a class room. I'm using Node version 11.11.0. This app has two files: index.js and student.js. The relevant code looks like this: index.js const EventEmitter = require('events'); const Student = require('./student'); async function start() { eventEmitter.on('newListener', (event, listener) => { console.log(`Added ${event} listener.`); }); eventEmitter.on('handRaised', (question) => { console.log(question); }); for (let i=0; i<10; i++) { let student = new

Angular EventEmitter from component to app.component

我与影子孤独终老i 提交于 2019-12-24 08:57:55
问题 I would like to bind an event emitter from a child to a parent component, but the parent component is the 'app.component'so i assume that the relationship between the two is not declared but implicit. in this answer , i see how to add an event emitter to a child that has been explicitly declared as such, in his parent: <child (notifyParent)="getNotification($event)"></child> But in my app, the child component (lets call id: child), is not declared in that way, but its declared in the app

Unable to catch events from EventEmitter in Angular2?

£可爱£侵袭症+ 提交于 2019-12-23 08:00:08
问题 I have written a basic angular application that utilises the EventEmitter class, however i cannot get the listening component to catch the event. Here is my code (using alpha.27 on Angular2 / TypeScript 1.5 compiling to ES5) Apologises for the verbose example. Any advice on what i am incorrectly doing what would be greatly appreciated. import {Component, View, EventEmitter} from 'angular2/angular2'; @Component({ selector: 'login', events : ['loggedIn'] }) @View({ template: '<button type=

Angular 2: Displaying icons in navbar on authentication

五迷三道 提交于 2019-12-23 04:45:51
问题 My component structure looks roughly like this. My app component has a nav bar and router outlet. The nav bar has logo, some generic links and some specific links to be shown on user login and authentication only. The router outlet loads the home component or the wall component based on the routing url. The home component contains the login component which contains the customary user id, password and submit button. On submit, and upon successful login, the login component emits an event. Now,

node.js event listener in another source file

左心房为你撑大大i 提交于 2019-12-22 05:00:54
问题 I am trying to design a scenario where on a particular event getting triggered, I wanted a few listeners to perform some task. Trying to also manage S.R.P of code, I want to have the listeners in a different source file. I want to know if this is possible using event Emitter. Does event emitter only work on a single source file? var events = require('events'); var em = new events.EventEmitter(); exports.saveScheme = function (req, res) { var dal = dalFactory.createDAL(constants.SCHEME);

Angular Two-Way Data Binding and Watching for Changes in Parent Component

旧街凉风 提交于 2019-12-21 17:22:33
问题 It seems there is no way to watch changes in the parent component when using two-way data binding. I have a custom input component for collecting a tag list. Two-way data binding is setup and working between this component and its parent. // the parent component is just a form // here is how I'm adding the child component <input-tags formControlName="skillField" [(tags)]='skillTags' (ngModelChange)="skillTagUpdate($event)"></input-tags> In the parent component how do you watch the bound