[英]How to migrate angularjs Upload functionalities to Angular 9
I got the work to migrate my AngularJs code to Angular 9.... And I am stucked with Upload functionalities and they are following:我得到了将我的 AngularJs 代码迁移到 Angular 9 的工作。我被上传功能困住了,它们如下:
Upload.isFile(obj);上传.isFile(obj); //returns boolean to check if the object is file. //返回 boolean 以检查 object 是否为文件。
Upload.dataurltoblob(image Url, "some string"); Upload.dataurltoblob(图像 Url,“一些字符串”); //converts a dataurl to blob object. //将dataurl转换为blob object。
How to get same functionality in latest Angular version?如何在最新的 Angular 版本中获得相同的功能?
Function code: // First Upload function Function 代码://先上传 function
$scope.documentDetails = {}; $scope.documentDetails = {};
$scope.downloadFile = function (){ $scope.downloadFile = function (){
If(! Upload.isFile($scope. documentDetails.imageUrl))
{
// if true required logic is applied
}
} }
// Second Upload function // 第二次上传 function
function showImage(){ function showImage(){
if($scope.documentDetails.contentType == "image/tiff" )
{
$scope.documentDetails.imageUrl = Upload.dataurltoblob ($scope.documentDetails.imageUrl," tiff") ;
}
} }
Every $scope
property that is referenced in the html should be a public
member so it could be referenced from angular component html. html 中引用的每个$scope
属性都应该是public
成员,因此它可以从 angular 组件 html 中引用。
So:所以:
public documentDetails; // Should be public if referenced in the html
public downloadFile() {
If(!Upload.isFile(this.documentDetails.imageUrl))
{
// if true required logic is applied
}
}
public showImage() {
if(this.documentDetails.contentType == "image/tiff" )
{
this.documentDetails.imageUrl = Upload.dataurltoblob (this.documentDetails.imageUrl," tiff") ;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.