Commit c3a447fa authored by luhongyu's avatar luhongyu

入门教程练习

parent 3695f7ce
......@@ -4,5 +4,4 @@
.model-content {
width: 100%;
height: 100%;
}
<div class="model-content">
<input nz-input placeholder="Basic usage" [(ngModel)]="msg" (blur)="saveItem()" />
<div style="position: absolute; left: 200px; top: 100px; width: 800px;">
<!-- <div style="position: absolute; left: 200px; top: 100px; width: 800px;">
<input type="text" nz-input [(ngModel)]="item.text" (blur)="save()">
......@@ -18,8 +19,7 @@
<app-custom-hot-zone></app-custom-hot-zone>
<app-upload-video></app-upload-video>
<app-lesson-title-config></app-lesson-title-config>
</div>
</div> -->
</div>
\ No newline at end of file
import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef, ChangeDetectorRef} from '@angular/core';
import { Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef, ChangeDetectorRef } from '@angular/core';
import { NzInputModule } from 'ng-zorro-antd/input';
......@@ -9,89 +10,57 @@ import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, Ap
})
export class FormComponent implements OnInit, OnChanges, OnDestroy {
msg = "gt";
// 储存数据用
saveKey = "test_0011";
KEY = "test_01_gt1";
// 储存对象
item;
constructor(private appRef: ApplicationRef,private changeDetectorRef: ChangeDetectorRef) {
constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) {
}
ngOnInit() {
this.item = {};
// 获取存储的数据
(<any> window).courseware.getData((data) => {
const getData = (<any>window).courseware.getData;
getData(data => {
if (data) {
this.item = data;
this.msg = data.msg;
} else {
this.msg = "";
}
this.init();
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
}, this.saveKey);
}, this.KEY)
}
ngOnChanges() {
}
ngOnDestroy() {
}
init() {
}
/**
* 储存图片数据
* @param e
*/
onImageUploadSuccess(e, key) {
this.item[key] = e.url;
this.save();
}
/**
* 储存音频数据
* @param e
*/
onAudioUploadSuccess(e, key) {
this.item[key] = e.url;
saveItem() {
console.log("save: " + this.msg);
this.save();
}
/**
* 储存数据
*/
save() {
(<any> window).courseware.setData(this.item, null, this.saveKey);
(<any>window).courseware.setData({ msg: this.msg }, null, this.KEY);
this.refresh();
}
/**
* 刷新 渲染页面
* 立即执行
*/
refresh() {
setTimeout(() => {
this.appRef.tick();
}, 1);
}
}
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment