I have a problem where by a form within my ng-controller
doesnt seem to change the properties in the controller that I thought it would. After some reading around it seems I wasn't fully aware of prototypal inheritance, but thanks to the internet and SO I updated my code as such. But unfortunately its still not working and I cannot figure out why.
Here is my HTML
<div ng-app="licenceApp" ng-controller="licenceController">
<div class="hover panel" ng-class="{switch : licenceFormVisible}">
<div class="highlightedSection nosidepad clearfix back">
<div class="highlightedSubSection" ng-class="{fullsize : uploadModel.active}" ng-show="!Applying && !FinishedWithErrors && !offlineActivationScreenVisible">
<h2>Licence File</h2>
Upload and apply a valid licence file{{uploadModel.active}}<br /><br />
...
<form id="hiddenUploadForm" name="hiddenUploadForm" target="hiddenUploadFormFileTarget" action="/settings/uploadILP" method="post" enctype="multipart/form-data" style="display: none;">
<input id="hiddenUploadFormFile" name="file" type="file" ng-model="uploadModel.uploadFileName" onchange="angular.element(this).scope().uploadFileChanged()" />
<iframe id="hiddenUploadFormFileTarget" name="hiddenUploadFormFileTarget" iframe-onload="uploadFileFinished()"></iframe>
</form>
</div>
</div>
</div>
ViewModel
angular.module('licenceApp.controllers', [])
.controller('licenceController', ['$scope', 'licenceAPIservice', '$filter', '$timeout', function ($scope, licenceAPIservice, $filter, $timeout) {
$scope.uploadModel = {
active: false,
uploadFileName: "",
uploading: false
};
$scope.uploadFileChanged = function () {
$scope.uploadModel.active = true;
$scope.uploadModel.uploading = true;
$('#hiddenUploadForm').submit();
}
...
So when I change uploadModel.active
in a function it shows the correct value through a console.log
but the display doesnt mimic the new value! Am I still subject to prototypal inheritance here? Note that uploadFileChanged
is hit when the input file control is changed.