Skip to content

Instantly share code, notes, and snippets.

Last active Aug 29, 2015
What would you like to do?
view using ng-file-upload
<section data-ng-controller="PostsController">
<form name="postForm" class="form-horizontal col-md-6" role="form" data-ng-submit="create(postForm.$valid)" novalidate>
<div class="form-group" ng-class="{ 'has-error' : submitted && postForm.content.$invalid }">
<label mean-token="'create-post'" class="col-md-3 control-label">Post</label>
<div class="col-md-offset-4">
<div>WOD: <input type="text" data-ng-model="wod" /></div>
<div>Meals: <input type="text" data-ng-model="meals" /></div>
<div>Stress: <input type="text" data-ng-model="stress" /></div>
<input type="hidden" data-ng-model="selfie">
<button ng-file-select="" ng-model="files" multiple="false"><span class="glyphicon glyphicon-camera"></span></button>
<img ng-src="posts/assets/img/posts/{{selfie}}" />
<div class="col-md-offset-4">
<textarea name="content" class="form-control" data-ng-model="content" id="content" placeholder="Content" cols="30" rows="10" required></textarea>
<div ng-show="submitted && postForm.content.$invalid" class="help-block">
<p ng-show="postForm.title.$error.required">Post cannot be blank</p>
<div class="form-group">
<div class="col-md-offset-3 col-md-9">
<button mean-token="'create-submit'" type="submit" class="btn btn-info">Submit</button>
$scope.$watch('files', function() {
for(var i = 0; i < $scope.files.length; i++){
var file = $scope.files[i];
$scope.upload = $upload.upload({
url: '/uploads',
data: {myObj: $scope.MyModelObj},
file: file
//console.log('progress: ' + parseInt(100.0 * evt.loaded/ + '% file: ' +;
}).success(function(data, status, headers, config){
$scope.selfie = data;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment