GithubHelp home page GithubHelp logo

alexpchin / angular-bootstrap-file-field Goto Github PK

View Code? Open in Web Editor NEW

This project forked from itslenny/angular-bootstrap-file-field

0.0 1.0 0.0 180 KB

A pure angular (no jquery) file field that functions like the native file input field but is displayed as a bootstrap button (also works without bootstrap see "styling" below) instead of the ugly system file upload field.

Home Page: http://itslenny.github.io/angular-bootstrap-file-field/

License: MIT License

Shell 10.04% HTML 63.51% JavaScript 26.45%

angular-bootstrap-file-field's Introduction

Angular Bootstrap File Field

A pure angular (no jquery) file field that functions like the native file input field but is displayed as a bootstrap button (also works without bootstrap see "styling" below) instead of the ugly system file upload field.

Adds support for ng-model and image preview.

Actions speak louder than words: Check out THE DEMO.

##Installation

Dependencies: Angular

Download and include angular-bootstrap-file-field.min.js

Create an angular app and inject bootstrap.fileField. That's about it.

bower

bower install angular-bootstrap-file-field

##Usage

Minimal

<file-field ng-model="uploadFile">Add File</file-field>

Show file name

<file-field ng-model="uploadFile">Add File</file-field>

{{uploadFile.name}}

Show image preview

<file-field ng-model="uploadFile" preview="previewImage">Select File</file-field>

<img ng-src="{{previewImage}}">

##Configuration

Options

Name Values Description
ng-model scope variable Behaves like ng-model on any other form element. Just binds to the $scope value in the controller.
preview scope variable Optional. If provided a base64 encoded image url will be provided. (this can be used in the ng-src or an img tag to display a preview

##Styling

This directive creates a <button> tag and gives it the class bootstrap class "btn" if no class or ng-class is specified.

####Example styling

bootstrap primary button

<file-field class="btn btn-primary" ng-model="foo"></file-field>

custom classes

<file-field class="myCustomClass" ng-model="foo"></file-field>

dynamic class

file-field also has full support for ng-class which can be used in conjunstion with the model attribute to make the button change classes (colors) once you select a file.

<file-field class="btn" ng-class="{'btn-success':foo}"  ng-model="foo"></file-field>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.