0

Here i'm using anguar with bootstrap i'm able to binding textvales not why my image not binding

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);

2 Answers 2

1
var i=file.name;
var x={
Image:i;
}
Sign up to request clarification or add additional context in comments.

Comments

0

Because in your $scope.Upload() function you are passing file and at var xx = {...} you are accessing it with $scope.file which would be undefined. Do:

var xx = {
    Image: file,
    Email: $scope.Email,
    password: $scope.password
}

5 Comments

no error but value not binding have u any alternate solution
could you log the variable xx and tell me its output?
xx = Object {Image: File, Email: undefined, password: undefined} 18 Image: file, file = File {name: "1.jpg", lastModified: 1479029060761, lastModifiedDate: Sun Nov 13 2016 14:54:20 GMT+0530 (India Standard Time), webki
What are you expecting to have?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.