Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger flow-btn / file browsing from controller #319

Open
albaad opened this issue Jan 5, 2017 · 2 comments
Open

Trigger flow-btn / file browsing from controller #319

albaad opened this issue Jan 5, 2017 · 2 comments

Comments

@albaad
Copy link

albaad commented Jan 5, 2017

I am using a modal to preview and generally manage my file uploads. You get there via an 'upload files' button in the main template. My flow-init and whole ng-flow enchilada is done within the modal.

Problem is, I would like to force file browsing when loading this modal if a certain array where I keep track of the uploaded files happens to be empty. So the user doesn't have to go through an unnecessary second step that first time.

I've tried triggering the DOM element holding flow-btn attribute to no avail.

Any way of accomplishing this?

@jbrady89
Copy link

+1 Looking for this as well. My particular use case would be triggering the flow-btn (in this case opening the file browser dialog) functionality from within a controller. Documentation makes no mention of this capability.

@dashawk
Copy link

dashawk commented Jan 22, 2018

Maybe you can create a directive that triggers a click event for the flow-btn.

directive('flowBtnTrigger', function () {
    return {
        scope: {
            flowBtnTrigger: '=',
        },
        link: function (scope, element, attr) {
            scope.$watch('flowBtnTrigger', function (newValue) {
                if (newValue) {
                    element.trigger('click');
                }
            });0
        }
    };
});

then use it like:

<div class="my-btn" flow-btn flow-btn-trigger="shouldTrigger()"></div>

then in your controller:

    $scope.CONDITIONS = false;
    $scope.shouldTrigger = function () {
            // Manipulate your conditions here
            $scope.CONDITIONS = true;

            // then return the resulting value;
            return $scope.CONDITIONS;
    };

I'm not sure though if this works. I haven't tested it. This is just my idea of implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants