angular-base64-upload
angular-base64-upload copied to clipboard
Model not updating in controller
I have an issue where in my view i have
<input type="file" ng-model="attachment" class="ion-paperclip text-right float-right attachment" base-sixty-four-input onerror="errorHandler" onchange="fileChanged"/>
For one I have fileChanged defined in the controller and everytime I add a file that function comes up as undefined.
For two I have a div with {{attachment}} this is showing up correctly for when I add the file, but when I go to use that file in another function $scope.attachment, it's coming up as undefined.
Any help would be appreciated.
Sean
It's on-change="fileChanged"
I fixed that but $scope.attachment is still undefined after I do a file upload
Can you post your code and angular version?
Angular is 1.3.6
In my controller all I have is.
$scope.attachment={};
$scope.sendMessage = function () {
console.log($scope.attachment.filename);
};
<div class="col col-10 text-right">
<input type="file" ng-model="attachment" class="ion-paperclip text-right float-right attachment" base-sixty-four-input onerror="errorHandler" on-change="fileChanged"/>
</div>
Take a look at this plunkr code and see what's missing in your code.
The only thing different I see is that i'm loading my controller from my module with stateprovider.
$stateProvider
.state('inbox.landing', {
url: '/landing',
views: {
'bodyContent': {
templateUrl: 'js/modules/inbox/inbox.html',
controller: 'InboxCtrl'
}
}
Are you triggering sendMessage()
within fileChanged()
?
No, i was just seeing what the value of the attachment, I don't need to use fileChanged if it will update the scope variable.
Also validation is not firing for me either.
Hi @dracostheblack , @adonespitogo Please how did you solde this issue of model not updating in controller? I am using Angular 1.5.7 I get undefined on debugging.
What is the solution?