javascript - AngularJS $scope.model is undefined -
angularjs $scope.model
undefined when initialize via javascript
<button ngf-select="upload($file)">Выбрать</button> <span id="photospan"></span> <input type="text" id="photo" name="uploadphoto" ng-model="uploadphoto">
here initialization code:
document.getelementbyid("photo").value = filename; $("#photospan").text(resp.config.data.file.name); console.log('success ' + resp.config.data.file.name + 'uploaded. response: ' + resp.data);
so
createexpositionresource.photo = $scope.uploadphoto; console.log('--------------'+$scope.uploadphoto);
returns undefined
.
what doing wrong?
thank you!
what doing wrong?
using jquery: have @ question: "thinking in angularjs" if have jquery background?
you should replace
document.getelementbyid("photo").value = filename;
by
$scope.uploadphoto = filename;
short explanation : if update angular variable (eg : document.getelementbyid("photo").value = filename;
), angular won't know did it. there worse code. angular, what's in $scope
"trusted data source". means angular erase value put using jquery.
Comments
Post a Comment