angular-file-model

WebJar for angular-file-model

License

License

MIT
Categories

Categories

Github Development Tools Version Controls Angular User Interface Web Frameworks
GroupId

GroupId

org.webjars.bower
ArtifactId

ArtifactId

github-com-ghostbar-angular-file-model
Last Version

Last Version

0.3.1
Release Date

Release Date

Type

Type

jar
Description

Description

angular-file-model
WebJar for angular-file-model
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/ghostbar/angular-file-model

Download github-com-ghostbar-angular-file-model

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bower/github-com-ghostbar-angular-file-model/ -->
<dependency>
    <groupId>org.webjars.bower</groupId>
    <artifactId>github-com-ghostbar-angular-file-model</artifactId>
    <version>0.3.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bower/github-com-ghostbar-angular-file-model/
implementation 'org.webjars.bower:github-com-ghostbar-angular-file-model:0.3.1'
// https://jarcasting.com/artifacts/org.webjars.bower/github-com-ghostbar-angular-file-model/
implementation ("org.webjars.bower:github-com-ghostbar-angular-file-model:0.3.1")
'org.webjars.bower:github-com-ghostbar-angular-file-model:jar:0.3.1'
<dependency org="org.webjars.bower" name="github-com-ghostbar-angular-file-model" rev="0.3.1">
  <artifact name="github-com-ghostbar-angular-file-model" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bower', module='github-com-ghostbar-angular-file-model', version='0.3.1')
)
libraryDependencies += "org.webjars.bower" % "github-com-ghostbar-angular-file-model" % "0.3.1"
[org.webjars.bower/github-com-ghostbar-angular-file-model "0.3.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.bower : angular jar [1.3,)

Project Modules

There are no modules declared in this project.

angular-file-model Code Climate

Simple Angular.js directive that allows input element's of type file to be handled in models inside a controller's scope.

Usage

Install with bower:

bower install angular-file-model --save

Add to your HTML files:

<script src='/bower_components/angular-file-model/angular-file-model.js'></script>

Now, inject to your application:

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

Ready to use in your controllers!:

file.html:

<input type='file' file-model='fileModel'>
<button type='button' ng-click='upload()'>Upload</button>

controller.js:

var DemoCtrl = [
  '$scope', 
  function ($scope) {
    $scope.upload = function () {
      $scope.fileModel // This is where the file is linked to.
    };
  }
]

Need an actual demo?

Go and check this out http://plnkr.co/edit/0ZHCsR.

Known Issues

  • Using a the modal controller from angular-ui I can't update the variable assigned to file-model: This is not an issue directly with angular-file-model. It's created because the modal controller uses transclusion. Actually, you can't update any other values directly. My workaround for this has been passing an empty object to the controller's scope and putting the file-model (just like other data from fields from the modal) into that object, so what I pass to file-model is something like: 'data.file' instead and it works. (data being already initialized as {} at least in the controller)

Author

© 2014, Jose Luis Rivas <[email protected]>.

License

The files are licensed under the MIT terms.

Versions

Version
0.3.1