# @controller

The @controller directive attaches a controller class to the component. The controller class must be registered in a module.

# Usage

Syntax

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

# Example

This example demonstrates the directive syntax.

<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>