Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ngModel not being set after upload #32

Open
jayrmotta opened this issue Jul 23, 2014 · 3 comments
Open

ngModel not being set after upload #32

jayrmotta opened this issue Jul 23, 2014 · 3 comments

Comments

@jayrmotta
Copy link

Hi,

I've trying to use this directive for a while and now I'm stuck trying to set the remote url to a variable in my controller.

<div s3-upload bucket="'my-videos'" ng-model="video.url" s3-upload-options="{getOptionsUri: '/ws/config'}"></div>

After the upload a url appears by on a link called "Stored file" pointing to the correct URL but the ngModel is not set on my controller.

I've debugged the directive and suspected about the ngModel being passed to the post link funciotn of the directive, it doesn't seem to be the one I've set on the div above.

Would you guys be able to help me figure out how to get the generated url?

Thanks in advance.

@btoone
Copy link

btoone commented Aug 12, 2014

What does your controller look like? I had the same issue but forgot I was using the controllerAs syntax so I just had to prefix the model.

Sorry I misread the first part of your question. I'm also wondering the best way to set the key (remote url) to a variable in the controller. Currently I have this working using a $watch but using a $watch in the controller isn't really the best idea. See my code below.

FYI I've asked in issue #36 if there is a better way. I think it would be ideal to have the events include the value so we could simply add a listener in the controller.

  $scope.$watch('vm.url', function(nv, ov) {
    console.debug(nv)
  });

@davidstanley01
Copy link

On success, the service will emit a "s3upload:success" event. Just listen for that like so:

$scope.$on('s3upload:success', function(event, response, url) {
    console.log(url);
});

@asafdav
Copy link
Owner

asafdav commented Oct 7, 2014

ng-model should be updated, I tried to reproduce it but couldn't.

The event should be used in order to avoid watching the value and get notified after the upload was completed.

Has any of you experienced the same issue ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants