Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

請問如何將 data 傳給 dialog #4

Closed
thomas0728 opened this issue Jul 25, 2017 · 2 comments
Closed

請問如何將 data 傳給 dialog #4

thomas0728 opened this issue Jul 25, 2017 · 2 comments

Comments

@thomas0728
Copy link

看了文件說明,可以透過 Data 傳資料給 DialogComponent ,但沒有範例,不知如何使用
感謝

@1inus
Copy link
Owner

1inus commented Jul 27, 2017

pass data to DialogComponent like this:

this.dialog.dialog({
	title: "lex 公式编辑器",
	dialogComponent: TargeComponent,
	isModal: false,
	data: {
		mathlex: mathlex,
		parentCallback: (lex, svg) => { · · · }
	}
});

then access data (data is not available before ngOnInit)

@Component({
	selector: "mathjax",
	template: ` . . . <button [disabled] ="!mathlex" (click)="done();">done</button>  . . .  `
})
export class MathDialog {
	private mathlex;
	private parentCallback;

. . .

	constructor(private ly:NgLayerRef) {}

	private done(){
		/*data from parent component*/
		console.log(this.mathlex);

		/*a callback function from parent component*/
		this.parentCallback(this.sourceLex, this.mathSvg);

		this.ly.close();
	}
}

@1inus 1inus closed this as completed Jul 28, 2017
@thomas0728
Copy link
Author

讚,另外也可透過 service 來傳遞,但沒那麼漂亮就是了
thank's

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants