<!DOCTYPE html>
<html data-ng-app='myApp'>
<head>
<meta charset='utf-8'>
<title>Index</title>
<script src='https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js'></script>
<script src='https://rawgit.com/ghostbar/angular-file-model/master/angular-file-model.js'></script>
<script type="text/javascript" charset="utf-8">
var app = angular.module('myApp', ['file-model']);
app.controller('DemoCtrl', function ($scope) {
$scope.file = null;
$scope.$watch('file', function (newVal) {
if (newVal)
console.log(newVal);
})
});
</script>
</head>
<body data-ng-controller='DemoCtrl'>
<h1>angular-file-model</h1>
<p>Here you can test <code>angular-file-model</code>.</p>
<p>If you like it, go grab the code at <a href='https://github.com/ghostbar/angular-file-model'>github</a> or bower (with <code>bower install angular-file-model</code>)!</p>
<form>
<input type='file' file-model='file'>
</form>
<p ng-if='file'>
The name of your file is {{ file.name }} and the size is of {{ file.size }} bytes.
</p>
<p ng-if='file'>
If you want to have something like ngChange the best way ATM is to use a $scope.$watch over the variable you pass to file-model just like in this code.
</p>
</body>
</html>
angular-file-model
==================
A small and lightweight directive that allows you to use something like ng-model in input fields type file.