我正在使用事物板演示版本3.0.1。 我想通过使用自定义窗口小部件来切换仪表板状态。 因此,我使用了自定义窗口小部件方法,并形成了一键式按钮小部件,该按钮是其他人在做同样事情的帖子中引用的。但是无论何时单击该小部件都不会发生任何事情。
HTML:
=====
<div fxFlex fxLayout="column" style="height: 100%;" fxLayoutAlign="space-around stretch">
<h3 style="text-align: center;">My first static widget.</h3>
<button mat-raised-button color="primary" (click)="showAlert()">Click me</button>
</div>````
JS:
==
self.onInit = function() {
self.ctx.$scope.showAlert = function() {
var alertContent = self.ctx.settings.alertContent;
if (!alertContent) {
alertContent = "Content derived from alertContent property of widget settings.";
}
window.alert(alertContent);
Widgetcontext.statecontroller.openState("Setting", params, false);
};
}
self.onDestroy = function() {
}
SETTING SCHEMA:
================
{
"schema": {
"type": "object",
"title": "Settings",
"properties": {
"alertContent": {
"title": "Alert content",
"type": "string",
"default": "Content derived from alertContent property of widget settings."
}
}
},
"form": [
"alertContent"
]
}
请帮助我任何人,并可能共享至少能正常工作的小部件或代码。 谢谢