这里我有folderObjs数组,这个数组的控制台在下面的代码中,我放置了搜索输入字段,我想通过文件夹名称和文件夹大小以角度搜索这个数组,这怎么可能?
HTML
<mat-form-field>
<input matInput (keyup)="applyFilter($event.target.value)" placeholder="Search">
</mat-form-field>
<div *ngFor="let folder of folderObjs">
<span>{{folder.folderName}}</span>
<span>{{folder.folderSize}}</span>
</div>
Run Code Online (Sandbox Code Playgroud)
TS
folderObjs : Folder[] = [];
applyFilter(filterValue) {
console.log(this.folderObjs);
// 0: {folderid: 781, folderName: "pelu folder",folderActivity: "true", …}
1: {folderid: 782, folderName: "biju folder", folderActivity: "true", …}
filter: "d"
length: 2
this.folderObjs.filter = filterValue.trim().toLowerCase();
}
Run Code Online (Sandbox Code Playgroud) (我参考此链接以了解https://github.com/angular/angular-cli/issues/2662),我在angular.json中添加add css并导入库instyle.css(它给出了类似./src/styles的错误.css(./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./src/styles.css)),在angular的本地项目中安装材质图标库的正确方法是什么?
npm install material-design-icons-iconfont --save
Run Code Online (Sandbox Code Playgroud)
angular.json
"styles": [
"src/styles.css",
"../node_modules/material-design-icons/iconfont/material-icons.css",
],
Run Code Online (Sandbox Code Playgroud)
style.css
@import "~material-design-icons-iconfont/dist/material-design-icons";
Run Code Online (Sandbox Code Playgroud)
index.html
<link href="../material-design-icons-iconfont/dist/fonts/" rel="stylesheet">
Run Code Online (Sandbox Code Playgroud) 在这里,我插入用户详细信息 username、emailid 和 contactno,而 userid 是用户表的主键。
我的查询是当我插入重复的用户名或电子邮件时,如果在表中听到重复的记录,它不允许插入记录怎么可能?
应用程序.js
app.post('/saveNewUserDetails',function(req,res){
var form = new multiparty.Form();
form.parse(req, function(err, fields, files){
connection.query("INSERT INTO user (username,emailid,contactno) VALUES (?,?,?)", [fields.username,fields.emailid,fields.contactno] , function (error, results, fields) {
if (error) throw error;
res.send({
'status':'1',
'success': 'true',
'payload': results,
'message':'New user Is saved'
});
});
});
});
Run Code Online (Sandbox Code Playgroud)
用户
userid(primary key) username emailid contactno
1 user-1 user1@user1.com 1234567890
2 user-2 user2@user2.com 1234444444
Run Code Online (Sandbox Code Playgroud) 我想尝试下载图像点击按钮,但是当我点击按钮时,这不是下载图像而是直接打开图像,但我想下载图像,那么如何在 reactjs 中下载图像?
<a
href="https://timesofindia.indiatimes.com/thumb/msid-70238371,imgsize-89579,width-400,resizemode-4/70238371.jpg"
download
>
<i className="fa fa-download" />
</a>
Run Code Online (Sandbox Code Playgroud) 我使用 *ngFor 遍历 div 中的数组。在这个 div 中有另一个带有 *ngIf else 条件的 div,其中 else 条件匹配 25 个值。
我的查询是我只想打印第一个值而不是 25 个值,而其他 24 个值应该隐藏或忽略。请注意,与 if 语句匹配的其他 25 个值都应该是可见的。怎么可能?
<div *ngFor="let item of messageArray; let index = index">
<div *ngIf="userids == item.userid;else other_content">{{item.username}}</div>
<ng-template #other_content>{{item.username}}</ng-template>
</div>
Run Code Online (Sandbox Code Playgroud)
app.component.ts
constructor(private socketService : SocketserviceService) {
this.socketService.newMessageReceived().subscribe((data) => {
this.messageArray = data.payload;
});
};
Run Code Online (Sandbox Code Playgroud) uploadFiles(): void {
const dialogRef = this.dialog.open(AddNewFilesOrImagesComponent, {
width: '620px',
height : '100%',
});
}
Run Code Online (Sandbox Code Playgroud)
如果高度为100%的用户界面看起来像这样(在“上传”按钮下,则不必留空白)
如果我将固定高度放到px中(它会使UI滚动)
uploadFiles(): void {
const dialogRef = this.dialog.open(AddNewFilesOrImagesComponent, {
width: '620px',
height : '250px',
});
}
Run Code Online (Sandbox Code Playgroud)
如果我选择文件,我想要实际的这种类型,它会自动增加其高度(当我选择图像时,我想增加matdialogbox的自动高度)