import { Component, OnInit, Inject } from '@angular/core'; import {MatTreeFlatDataSource, MatTreeFlattener} from '@angular/material/tree'; import {FlatTreeControl} from '@angular/cdk/tree'; import { HttpClient } from '@angular/common/http'; import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog'; import {FormControl} from '@angular/forms'; import { MatSnackBar } from '@angular/material/snack-bar'; @Component({ selector: 'lookmaster', templateUrl: './lookmaster.component.html', styleUrls: ['./basicinfo.component.scss'] }) export class LookMaster { // myControl = new FormControl(); //注入MatDialogRef,可以用来关闭对话框 //要访问对话框组件中的数据,必须使用MAT_DIALOG_DATA注入令牌 constructor(private http: HttpClient,public dialogRef: MatDialogRef,@Inject(MAT_DIALOG_DATA) public data) {} allunittype:any ImgUrl:string rotationAngle=0 isheng:any isshowimg:boolean onNoClick(): void { this.dialogRef.close(); } ngOnInit(): void { if(this.data.img.indexOf('?') == -1){ this.isshowimg = false }else{ this.isshowimg = true var imgurl = this.data.img.split("?") this.ImgUrl = imgurl[0] } } //点击旋转按钮时 rotateA = 0 rotateB = 0 rotate(){ var w= document.getElementsByClassName("imgitemdefault")[0]['naturalWidth']; var h = document.getElementsByClassName("imgitemdefault")[0]['naturalHeight']; if(w > h){ this.isheng = true }else{ this.isheng = false } if(this.isheng){ this.rotateA += 90 if(this.rotateA == 360){ this.rotateA = 0 } }else{ this.rotateB += 10 if(this.rotateB == 40){ this.rotateB = 0 } } } }