Giter Club home page Giter Club logo

Comments (5)

koz1ma avatar koz1ma commented on June 24, 2024 6

I was able to make it work by changing the way the file input is manipulated. I create a directive to check the file input like:

app.directive('customOnChange', function () {
    return {
        restrict: 'A',
        link: function (scope, element, attrs) {
            var onChangeHandler = scope.$eval(attrs.customOnChange);
            element.bind('change', onChangeHandler);
        }
    };
});

then in the html:

<div>Select an image file: <input custom-on-change="handleFileSelect" type="file" id="fileInput"/></div>

and inside the modal controller:

$scope.handleFileSelect = function (evt) {
        var file = evt.currentTarget.files[0];
        $scope.$apply(function ($scope) {
            $scope.myImage = URL.createObjectURL(file);
        });
    };

from ngimgcrop.

tapesec avatar tapesec commented on June 24, 2024 1

Hi,

I've had the same probleme and i resolved it like you, with $timeout but without delay.
$timeout(function() {
}/* no delay here */);

It's probably because the modal opening is an async action and you have to delay the directive DOM loading in order that they not be run in the same cycle.

from ngimgcrop.

coffeeboss avatar coffeeboss commented on June 24, 2024

Although I don't have the code anymore, as I've changed from a modal back into a regular page for another reason, I didn't need to set a timeout. Just my 2c

from ngimgcrop.

MatthieuLebigre avatar MatthieuLebigre commented on June 24, 2024

Hi, I'm having exactly the same issue : but copying the sample code into a modal, it doesn't work.
Adding a time with no delay fix the issue ...

from ngimgcrop.

SimonStiph avatar SimonStiph commented on June 24, 2024

Matthieu, if the code running in an instance of a child controller for ngImgCrop, try to keep the controller the same as the parent. Both UI-Bootstrap and AngularStrap allow you to do both methods, but I had greater success with the parent controller.

from ngimgcrop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.