how to distinguish between value set by user interaction vs binding on a Spark input component
Date : March 29 2020, 07:55 AM
may help you . How do I determine whether a value set comes from user interaction with the input component, or from binding? , listen for the change event. It will solve your problem. <s:HGroup>
<s:NumericStepper change="trace('ns change')" value="{ns2.value}" minimum="{ns2.minimum}" maximum="{ns2.maximum}"/>
<s:NumericStepper minimum="0" maximum="1000" id="ns2" />
</s:HGroup>
|
Component interaction in Angular 2 RC5
Date : March 29 2020, 07:55 AM
it should still fix some issue I want to create interaction between components which are not parents or children : they are in different NgModules. I imagined a service, where I inject my component, but it seems to not be possible. And I can't inject too my component in the other component (cause they are not parent/child). But they have a common parent (AppComponent). How could I do to make communicate my components ? , You definitely can use services. Something like that: import { EventEmitter } from '@angular/core';
export class SharedService {
pushedData = new EventEmitter<string>();
private data: string[] = [];
addData(input: string) {
this.data.push(input);
}
getData() {
return this.data;
}
pushData(value: string) {
this.pushedData.emit(value);
}
}
|
Component Interaction Angular 2
Date : March 29 2020, 07:55 AM
wish of those help This is one way of doing it : load service in parent component and share it with all child Parent Component import { Svc } from '../services/mySvc.svc'
@Component({
.......
providers: [Svc]
template:`<child1></child1>
<child2></child2>`
})
export class TerminalComponent implements OnInit {
import { Svc } from '../services/mySvc.svc'
@Component({
selector: 'child1',
......
})
export class Child1Component implements OnInit {
constructor(private _editCompSvc: Svc){}
}
import { Svc } from '../services/mySvc.svc'
@Component({
selector: 'child1',
......
})
export class Child2Component implements OnInit {
constructor(private _editCompSvc: Svc){}
}
|
Angular component interaction issue
Date : March 29 2020, 07:55 AM
will help you Remove the public keyword in both parent and child component.ts, it should work fine public name = "Vishwas"; // public not necessary
@Input() public parentData; //public not necessary
<app-test *ngIf="name" [parentData]="name"></app-test>
ngOnInit() {
console.log(this.parentData);
}
|
Sibling component interaction in angular 2
Date : March 29 2020, 07:55 AM
To fix the issue you can do You need EventEmitter to emit the event on setdata() and subscribe that event to get that data : Like this: you should call setdata() with data as parameter: import { Injectable, Output, EventEmitter } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class DataService{
@Output() open: EventEmitter<any> = new EventEmitter();
setdata(data){
this.open.emit(data);
}
}
constructor(private data: DataService) { }
functionCall(){
this.data.setdata(data);
}
constructor(private data: DataService) { }
ngAfterViewInit() {
this.data.changeClasss.subscribe(data => {
this.yourData = data
});
}
|