这里我正在使用带有bootstrap的anguar我能够绑定textvales而不是为什么我的图像没有绑定
HTML
<div ng-controller="MyCntrl">
<input type="text" placeholder="Emil" ng-model="Email" />
<input type="file" name="file" accept="image/*" ng-model="Image" ngf-select>
<img ngf-thumbnail="Image" />
<input type="button" class="btn btn-sm btn-primary" value="Login" ng-click="Uplode(Image)" />
</div>
Angular.Js
$scope.Uplode = function (file) {
if ($scope.Image != null) {
// if ((Image.type == 'image/png' || Image.type == 'image/jpeg' || Image.type == 'image/gif') && Image.size <= (512 * 1024)) {
if (file.type == 'image/png' || file.type == 'image/jpg' || file.type == 'image/gif' || file.type == "image/jpeg")
{
if (file.size <= (512 * 1024))
{
if (file == file)
{
for (var i = 0; i < file.length; i++) {
dataAsFormData.append(file[i].name, file[i]);
}
}
var xx = {
Image: $scope.file,
Email: $scope.Email,
password: $scope.password,}
var service = MyserviceContect.DataSave(xx);
答案 0 :(得分:1)
var i=file.name;
var x={
Image:i;
}
答案 1 :(得分:0)
因为在private function increment()
{
return MyClass::qt++;
}
函数中,您正在$scope.Upload()
和file
处通过var xx = {...}
访问它,这将是未定义的。
做:
$scope.file