Skip to content

@controller

@controller 指令将一个控件类附加到组件上。控件类必须在模块中注册。

用法

语法

html

<component-name @controller="module-name:ControllerName">

示例

以下示例演示了指令的语法。

详情
html

<html>
<template id="layout-template">
    <webpdf>
        <div>
            <xbutton @controller="custom:MyController">Click me</xbutton>
        </div>
        <div class="fv__ui-body">
            <viewer></viewer>
        </div>
    </webpdf>
</template>
</html>
<script>
    UIExtension.PDFUI.module('custom', [])
            .controller('MyController', {
                handle: function () {
                    alert('Button click!');
                }
            });
    var CustomAppearance = UIExtension.appearances.Appearance.extend({
        getLayoutTemplate: function () {
            return document.getElementById('layout-template').innerHTML;
        },
        disableAll: function () {
        }
    });
    var libPath = window.top.location.origin + '/lib';
    var pdfui = new UIExtension.PDFUI({
        viewerOptions: {
            libPath: libPath,
            jr: {
                licenseSN: licenseSN,
                licenseKey: licenseKey
            }
        },
        renderTo: document.body,
        appearance: CustomAppearance,
        addons: []
    });
</script>