File Upload with Angular Material

后端 未结 12 1234
抹茶落季
抹茶落季 2021-01-30 15:48

I\'m writing an web app with AngularJS and angular-material. The problem is that there\'s no built-in component for file input in angular-material. (I feel that file uploading d

12条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-30 16:44

    from jameswyse at https://github.com/angular/material/issues/3310

    HTML

    
     Choose Files 
    

    CONTROLLER

        var link = function (scope, element, attrs) {
        const input = element.find('#fileInput');
        const button = element.find('#uploadButton');
    
        if (input.length && button.length) {
            button.click((e) => input.click());
        }
    }
    

    Worked for me.

提交回复
热议问题