Last active
August 29, 2015 14:10
-
-
Save rekibnikufesin/6fcc66be908a11e502b2 to your computer and use it in GitHub Desktop.
view using ng-file-upload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> | |
<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> | |
</div> | |
<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> | |
</div> | |
</div> | |
</div> | |
</form> | |
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.$watch('files', function() { | |
if($scope.files){ | |
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 | |
}).progress(function(evt){ | |
//console.log('progress: ' + parseInt(100.0 * evt.loaded/evt.total) + '% file: ' + evt.config.file.name); | |
}).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