Using jqueryUi.resizeable() with AngularJs

后端 未结 1 1380
盖世英雄少女心
盖世英雄少女心 2021-02-10 11:36

I have a DOM element in one of my templates that I want to make resizable using jqueryUi. The long and short is that I have a

element in my template cal
1条回答
  •  情书的邮戳
    2021-02-10 12:21

    For such stuff, a directive is always the right way to go.
    To make an element resizable (with an optional callback), you should implement a directive like this:

    app.directive('resizable', function () {
        var resizableConfig = {...};
    
        return {
            restrict: 'A',
            scope: {
                callback: '&onResize'
            },
            link: function postLink(scope, elem) {
                elem.resizable(resizableConfig);
                elem.on('resizestop', function () {
                    if (scope.callback) scope.callback();
                });
            }
        };
    });
    

    Then, in the HTML:

    Hello, world !

    If you need varying resizable configurations, you can pass that to the isolate scope using an attribute.


    See, also, this short demo.

    0 讨论(0)
提交回复
热议问题