import { Component, OnInit, ViewChild } from '@angular/core';
import { TagService } from '../../services/tag.service';
import { AuthService } from '../../services/auth.service';
import { Tag } from '../../models/tag';
import { Company } from '../../models/company';
import { TagColumnDetail } from '../../models/tag-column-detail';
@Component({
selector: 'app-admin',
templateUrl: './admin.component.html',
styleUrls: ['./admin.component.css']
})
export class AdminComponent implements OnInit {
initialTagState: Tag[];
tags: Tag[];
updatedTags: Tag[];
constructor(
private tagService: TagService
) {}
@ViewChild(TableComponent) table:TableComponent;
ngOnInit() { this.authService.getActiveCompany$().subscribe((company: Company) => {
this.activeCompany = company;
if (this.activeCompany) {
Promise.all([
this.tagService.getColumns(),
this.tagService.getTags(this.activeCompany.Id)
]).then(([tagCols, tags]) => {
this.tagCols = tagCols;
this.setTags(tags, true);
this.initialTagState = JSON.parse(JSON.stringify(this.tags));
});
}
});
}
setTags(tags, init=false) {
this.tags = tags
if(!init) {
this.changesMadeToPolicy()
}
}
changesMadeToPolicy() {
let changes = this._getChanges(this.initialTagState, this.tags)
this.updatedTags = changes
}
_getChanges(oldArray, newArray) {
let changes, i, item, j, len;
if (JSON.stringify(oldArray) === JSON.stringify(newArray)) {
return false;
}
changes = [];
for (i = j = 0, len = newArray.length; j < len; i = ++j) {
item = newArray[i];
if (JSON.stringify(item) !== JSON.stringify(oldArray[i])) {
changes.push(item);
}
}
return changes;
};
}
在删除图片时出现错误,如何设置路径特定文件夹 错误:{[错误:ENOENT:没有这样的文件或目录,取消链接'D:\ officework \ server_code \ uploads \ documents \ user_id_id {_id:5c05a559c01f4b2eece9d897, 我的项目结构是office \ server_code \ uploads \ documents / user_id / id
答案 0 :(得分:0)
尝试这样做
filesystem.unlink("uploads/documents/user_id/"+result._id+".md", function(err) {
if(err) {
console.log(err);
} else {
console.log("Deleted the file: " + result +".md");
}
});