Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
N

ng-flow

> 编程语言
Open source

Flow.js html5 file upload extension on angular.js framework

1.4K stars0 likes1 views
WebsiteGitHub

About

Flow.js html5 file upload extension on angular.js framework

ng-flow

View angular2+ repo at https://github.com/flowjs/ngx-flow

ng-flow is a Flow.js extensions for angular.js framework, no 3rd party JS dependencies required!

Demo: http://flowjs.github.io/ng-flow/

How can I install it?

  1. Get the library:

Direct Download Download a latest build from https://github.com/flowjs/ng-flow/releases it contains development and minified production files in dist/ directory, they are also concatenated with core flow.js library.

Using NPM

bash
    npm install @flowjs/ng-flow --save

Using Bower

    bower install ng-flow#~2

Git Clone

bash
    git clone https://github.com/flowjs/ng-flow

Using Yeoman

    bower install "ng-flow#~2" --save
    grunt bower-install
  1. Add the module to your app as a dependency:

     angular.module('app', ['flow'])
     
  2. Include the files in your project

xml

<script src="ng-flow/dist/ng-flow-standalone.min.js"></script>

<script src="flow.js/dist/flow.min.js"></script>
<script src="ng-flow/dist/ng-flow.min.js"></script>

How can I use it?

First of all wrap places there you are going to use Flow.js

xml

This directive is going to add $flow variable to current scope. Also directive can be nested, because $flow variable is going to be overridden. $flow is instance of Flow.

Secondly you need to assign some upload buttons:

xml
<input type="file" flow-btn />
<input type="file" flow-btn flow-directory />
  Input OR Other element as upload button
<span flow-btn>Upload File</span>

First button is for normal uploads and second is for directory uploads. Note: avoid using <a> and <button> tags as file upload buttons, use <span> instead.

Now you need to display uploaded files, all you need to do is to loop files array. Files array is attached to flow object named $flow.

xml
<tr ng-repeat="file in $flow.files">
    <td>{{$index+1}}</td>
    <td>{{file.name}}</td>
</tr>

file is instance of FlowFile.

Quick setup

xml

Need more examples?

Clone this repository and go to "ng-flow/samples/basic/index.html". Single image upload "ng-flow/samples/image/index.html".

How can I drop files?

Use flow-drop directive:

xml

Note: in most cases flow-drop must be used together with flow-prevent-drop directive on body element, because it prevents file from being loaded in the browser.

Prevent dropping files on a document

Use flow-prevent-drop directive on body element:

xml
<body flow-prevent-drop>

</body>

How to add some styles while dropping a file?

Use flow-drag-enter directive:

xml

Note: flow-drag-leave attribute can't be used alone, it is a part of flow-drag-enter directive.

How to dynamically disable drop area?

xml

See example at samples/dataurl/.

How can I preview uploaded image?

Use flow-img directive:

xml

Image will be automatically updated once file is added. No need to start upload.

How can I set options for flow.js?

Use config:

javascript
var app = angular.module('app', ['flow'])
.config(['flowFactoryProvider', function (flowFactoryProvider) {
    flowFactoryProvider.defaults = {
        target: '/upload',
        permanentErrors:[404, 500, 501]
    };
    // You can also set default events:
    flowFactoryProvider.on('catchAll', function (event) {
      ...
    });
    // Can be used with different implementations of Flow.js
    // flowFactoryProvider.factory = fustyFlowFactory;
}]);

also can be configured on "flow-init" directive:

xml

How can I catch events?

Events are listed inside flow-init directive:

xml

</div>

How can I catch an event in a controller?

If controller is on the same scope as flow-init directive or in a child scope, then we can catch events with $on. Events are prefixed with flow::.

javascript
$scope.$on('flow::fileAdded', function (event, $flow, flowFile) {
  event.preventDefault();//prevent file from uploading
});

second argument is always a flow instance and then follows event specific arguments.

How can I assign flow to a parent scope?

Use flow-name attribute and set it to any variable in the scope.

xml
javascript
$scope.obj = {}; // variable "obj" must be initialized on the scope

How can I initialize flow with an existing flow object ?

Use flow-object attribute and set it with the existing flow object on scope.

xml

How can I support older browsers?

Go to https://github.com/flowjs/fusty-flow.js and add to your config:

javascript
var app = angular.module('app', ['flow'])
.config(['flowFactoryProvider', function (flowFactoryProvider) {
    flowFactoryProvider.factory = fustyFlowFactory;
}]);

Contribution

To ensure consistency throughout the source code, keep these rules in mind as you are working:

  • All features or bug fixes must be tested by one or more specs.

  • With the exceptions listed below, we follow the rules contained in Google's JavaScript Style Guide:

    • Wrap all code at 100 characters.

    • Instead of complex inheritance hierarchies, we prefer simple objects. We use prototypical inheritance only when absolutely necessary.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言