【问题标题】:Upload image within ng-submit form在 ng-submit 表单中上传图片
【发布时间】:2017-03-14 21:48:31
【问题描述】:

我是 Angular.js 的新手,我想知道如何在我的 ng-submit 表单中上传图片。它非常适用于下一个基于字段,但是对于文件,它只给我“选择文件”按钮,而在点击提交按钮后不显示它。

<form ng-submit="addartikel()">
<input type="text" placeholder="Bezeichnung" ng-model="newartikel.name" />
<input type="text" placeholder="Kategorie" ng-model="newartikel.kategorie" />
<input type="text" placeholder="Preis" ng-model="newartikel.preis" />
<input type="file" placeholder="Bild" ng-model="newartikel.thumb" />
<input type="submit" value="Artikel hinzufügen" />

至于控制器:

    webShop.controller('InventarController', ['$scope', '$http', function($scope, $http){

  $scope.addartikel = function(){
    $scope.inventar.push({
      name: $scope.newartikel.name,
      kategorie: $scope.newartikel.kategorie,
      preis: parseInt($scope.newartikel.preis),
      thumb: $scope.newartikel.thumb,
      available: true
    });

您的帮助将不胜感激:)

【问题讨论】:

    标签: angularjs forms upload


    【解决方案1】:

    使用 Angular 文件上传。在https://github.com/nervgh/angular-file-upload 中可用

    【讨论】:

      猜你喜欢
      • 2011-01-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-12
      • 1970-01-01
      • 1970-01-01
      • 2017-12-24
      相关资源
      最近更新 更多