Skip to content

Commit

Permalink
update README and module structure
Browse files Browse the repository at this point in the history
  • Loading branch information
vpegado committed Nov 2, 2014
1 parent 86c2270 commit 8a9d992
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bower_components/
53 changes: 28 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,36 @@ angular-file-directive
File parsing directive for AngularJS

## Installation
Install with [Bower](http://bower.io/):

$ bower install angular-file-directive

Include from a [RawGit](https://rawgit.com/)'s CDN:

<script src="//cdn.rawgit.com/vpegado/angular-file-directive/v1.1.0/file.js"></script>

Or [download](https://github.com/vpegado/angular-file-directive/archive/master.zip) manually.
Install with [Bower](http://bower.io/):
```bash
$ bower install angular-file-directiv
```

## Usage
`app.js`

angular.module('myApp', ['file']);


`view.html`

<!-- Bind the values to $scope.files -->
<input type="file"
file="files"
accept="image/*"
multiple>

<!-- Render the selected files directly in the view -->
<div ng-repeat="file in files">
<h4>{{ file.name }}</h4>
<img alt="{{ file.name }}"
Include the library:
```html
<script src="/bower_components/angular-file-directive/angular-file-directive.js"></script>
```

Import it to the angular applicaiton:
```javascript
angular.module('myApp', ['ngFile']);
```

Use it in the view:
```html
<!-- Bind the values to $scope.files -->
<input type="file"
file="files"
accept="image/*"
multiple>

<!-- Render the selected files directly in the view -->
<div ng-repeat="file in files">
<h4>{{ file.name }}</h4>
<img alt="{{ file.name }}"
ng-src="data:{{ file.type }};base64,{{ file.body }}">
</div>
</div>
```
2 changes: 1 addition & 1 deletion file.js → angular-file-directive.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

angular.module('file', [])
angular.module('ngFile', [])
.directive('file', [function () {
return {
scope: {
Expand Down
9 changes: 6 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"name": "angular-file-directive",
"version": "1.2.0",
"version": "1.3.0",
"homepage": "https://github.com/vpegado/angular-file-directive",
"authors": [
"Victor Pegado <[email protected]>"
],
"description": "Angular directive for parsing files",
"main": "file.js",
"main": "angular-file-directive.js",
"ignore": [
"example/*"
],
"keywords": [
"angular",
"file",
Expand All @@ -15,6 +18,6 @@
],
"license": "MIT",
"dependencies": {
"angular": ">=1.2.*"
"angular": "1.2.*"
}
}
4 changes: 4 additions & 0 deletions example/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
angular.module('fileApp', ['ngFile'])
.controller('FileCtrl', ['$scope', function($scope){
// Example controller
}]);
27 changes: 27 additions & 0 deletions example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<html>
<head>
<title>Example</title>
<script src="../bower_components/angular/angular.min.js"></script>
<script src="../angular-file-directive.js"></script>
<script src="app.js"></script>
</head>
<body ng-app="fileApp" ng-controller="FileCtrl">
<h1>Example</h1>

<!-- Bind the values to $scope.files -->
<input type="file"
file="files"
accept="image/*"
multiple>

<!-- Render the selected files directly in the view -->
<div ng-repeat="file in files">
<h4>{{ file.name }}</h4>
<img alt="{{ file.name }}"
ng-src="data:{{ file.type }};base64,{{ file.body }}">
<pre>{{ file | json }}</pre>
</div>


</body>
</html>

0 comments on commit 8a9d992

Please sign in to comment.