Posts

Showing posts with the label Dialog

Angular Material Dialog: How To Update The Injected Data When They Change In The Parent Component?

Answer : You can just change data of the component instance, like this: this.dialogRef.componentInstance.data = {numbers: value}; Example here: https://stackblitz.com/edit/angular-dialog-update There are 2 ways I can think of at the moment, I don't really like either, but hey... Both ways involve sending an observable to the dialog through the data. You could pass on the observable of the part to the part component, and then pass the observable in the data to the dialog. The dialog could then subscribe to the observable and get the updates that way. AreaComponent @Component({ selector: 'app-area', template: '<app-part *ngFor="let part of planAsync$ | async; i as index" [partData]="part" [part$]="part$(index)"></app-part>' }) export class AreaComponent { plan = []; constructor(private wampService: WampService) { } part$(index) { return this.planAsync$ .map(plan => plan[index]); ...

Android PreferenceActivity Dialog With Number Picker

Answer : Subclass DialogPreference to build your own NumberPickerPreference . I have implemented one below for you. It works perfectly fine, but is not feature complete. For example the minimum and maximum values are hard-coded constants. These should really be attributes on the preference xml declaration. To get that to work you would need to add an attrs.xml file specifying your custom attributes. For the full implementation of the NumberPicker preference widget that supports custom xml attributes in a library project and a demo app showing how to use it, see GitHub: https://github.com/Alobar/AndroidPreferenceTest You would use the widget as any other preference widget, except you have to fully qualify the name: preferences.xml <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <com.example.preference.NumberPickerPreference android:key="key_number" android:title="Give me a number" ...