好像没有办法绑定数据……可是直接用form提交的话会直接跳转,没办法做输入验证也没办法获取后端的返回值。
前端菜鸟望解答……
html
<form ng-submit="processForm()" enctype="multipart/form-data">
<div class="form-group">
<label class="label"><span class="tip" ng-hide="data.id">*</span>ID:</label>
<input class="input" name="id" ng-model="data.id" maxlength="5">
</div>
<div class="form-group">
<input type="file" name="preview" ng-model="data.preview">
</div>
<button type="submit" class="btn btn-default btn-small">保存</button>
</form>
js
$scope.processForm = function(){
var data = $scope.data,
url = Api.add,
config;
$http({
method: 'POST',
url: url,
data: data,
headers: {'Content-Type': undefined},
}).then(function(result){
找到解决方法了
http://blog.csdn.net/wei38908...
https://github.com/ghostbar/a...
html
弃用了题目里的directive,改用上面链接里的angular-file-model(文档写得挺详细的……)
保存的方法:
但是没看懂解决方法里的代码……感觉自己照抄来的也很粗糙……抛砖引玉吧……