What is ng-flow?
Flow.js extensions for angular.js framework, no 3rd party JS dependencies required!
ng-flow extension is based on Flow.js library.
Demo: http://flowjs.github.io/ng-flow/
How can I install it?
- 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 Bower
bower install ng-flow#~2
Git Clone
git clone https://github.com/flowjs/ng-flow
Using Yeoman
bower install "ng-flow#~2" --save
grunt bower-install
-
Add the module to your app as a dependency:
angular.module('app', ['flow'])
How can I use it?
First of all wrap places there you are going to use Flow.js
... other flow directives goes here ...
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:
First button is for normal uploads and second is for directory uploads.
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
.
{{$index+1}} {{file.name}}
file is instance of FlowFile.
How can I drop files?
Use flow-drop
directive:
Drag And Drop your file here
Prevent dropping files on a document
Use flow-prevent-drop
directive on body
element:
How to add some styles while dropping a file?
Use flow-drag-enter
directive:
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?
Drag And Drop your file here
See example at samples/dataurl/
.
How can I preview uploaded image?
Use flow-img directive:
Image will be automatically updated once file is added. No need to start upload.
How can I set options for flow.js?
Use config:
var app = angular;
also can be configured on "flow-init" directive:
How can I catch events?
Events are listed inside flow-init
directive:
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::
.
$scope;
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.
... Flow is set to obj.flow ... I have uploaded files: #{{obj.flow.files.length}}
How can I support older browsers?
Go to https://github.com/flowjs/fusty-flow.js and add to your config:
var app = angular;
Need example?
Clone this repository and go to "ng-flow/samples/basic/index.html". Single image upload "ng-flow/samples/image/index.html".
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.
-