Javascript 选择文件后的范围变量为';t改变了它的价值
选择文件后,我尝试将范围值更改为文件路径 这是html文件Javascript 选择文件后的范围变量为';t改变了它的价值,javascript,angularjs,Javascript,Angularjs,选择文件后,我尝试将范围值更改为文件路径 这是html文件 <input type="file" name="file" onchange="angular.element(this).scope().showFilePath(this)"> <div>{{filename}}</div> 其中console.log($scope.filename)显示“C:\fakepath\1m.jpg”,但在网页中仍然显示“请上传文件” 我该怎么处理 谢谢我希望你已经
<input type="file" name="file" onchange="angular.element(this).scope().showFilePath(this)">
<div>{{filename}}</div>
其中console.log($scope.filename)
显示“C:\fakepath\1m.jpg”,但在网页中仍然显示“请上传文件”
我该怎么处理
谢谢我希望你已经试过了
$scope.showFilePath = function(file) {
console.log(file.value)
$scope.filename = file.value
$timeout(function() {
$scope.$apply();
}, 1000)
}
我希望你已经试过了
$scope.showFilePath = function(file) {
console.log(file.value)
$scope.filename = file.value
$timeout(function() {
$scope.$apply();
}, 1000)
}
哦,行了!谢谢:)所以我们需要等待片刻,以便重新应用角度范围值,对吗?哦,这很有效!谢谢:)所以我们需要等待片刻,以便重新应用角度范围值,对吗?