Hi,
I'm having issue while trying to use function of the *parent controller* of
my *modal*.
>From the *parent controller* I open a *modal*, in the *modal* I do actions
and when I click on a button I want to use the function *parentOnChange* of
the *parent controller.*
To do this I pass the *parentOnChange* function of the *parent controller*
through
the *resolve* function of *IModalService*.
In *parentOnChange* I use other functions of the *parent controller*, the
problem is : keyword "*this*" in *parentOnChange *is not referring the *parent
controller* but to the *modal controller*, and I can't figure out how to
solve this :)
Any help would be appreciated ;)
Here is a simplified example :
*The parent controller*
export class Controller implements IComponentController {
public static $inject: string[] = [
'$uibModal'
];
constructor(
private readonly $uibModal: IModalService
) { }
private openContextMenu(object: MyInterface) {
const modal = this.$uibModal.open({
component: 'myContextMenuModal',
resolve: {
object: () => object,
onChange: () => this.parentOnChange
}
});
}
public parentOnChange(object: MyInterface) {
console.log(this);
this.oneFunction();
this.twoFunction(object);
}
}
*The modal*
export class Controller {
// Bindings
public readonly close: (data: any) => void;
public readonly dismiss: () => void;
public readonly resolve: {
object: MyInterface,
onChange(object: MyInterface) : void
};
public object: MyInterface;
public onChange: (object: MyInterface) => void;
public button_Click(): void {
...
this.Change(this.object);
...
}
}
export default {
template: htmlTemplate,
controller: Controller,
bindings: {
resolve: '<',
close: '&',
dismiss: '&'
}
};
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" 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 https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.