Commit c3a447fa authored by luhongyu's avatar luhongyu

入门教程练习

parent 3695f7ce
...@@ -4,5 +4,4 @@ ...@@ -4,5 +4,4 @@
.model-content { .model-content {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
<div class="model-content"> <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()"> <input type="text" nz-input [(ngModel)]="item.text" (blur)="save()">
...@@ -18,8 +19,7 @@ ...@@ -18,8 +19,7 @@
<app-custom-hot-zone></app-custom-hot-zone> <app-custom-hot-zone></app-custom-hot-zone>
<app-upload-video></app-upload-video> <app-upload-video></app-upload-video>
<app-lesson-title-config></app-lesson-title-config> <app-lesson-title-config></app-lesson-title-config>
</div> </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 ...@@ -9,89 +10,57 @@ import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, Ap
}) })
export class FormComponent implements OnInit, OnChanges, OnDestroy { export class FormComponent implements OnInit, OnChanges, OnDestroy {
msg = "gt";
// 储存数据用 // 储存数据用
saveKey = "test_0011"; KEY = "test_01_gt1";
// 储存对象 // 储存对象
item; item;
constructor(private appRef: ApplicationRef,private changeDetectorRef: ChangeDetectorRef) { constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) {
} }
ngOnInit() { ngOnInit() {
this.item = {};
// 获取存储的数据 // 获取存储的数据
(<any> window).courseware.getData((data) => { const getData = (<any>window).courseware.getData;
getData(data => {
if (data) { if (data) {
this.item = data; this.msg = data.msg;
} else {
this.msg = "";
} }
}, this.KEY)
this.init();
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
}, this.saveKey);
} }
ngOnChanges() { ngOnChanges() {
} }
ngOnDestroy() { ngOnDestroy() {
} }
saveItem() {
console.log("save: " + this.msg);
init() {
}
/**
* 储存图片数据
* @param e
*/
onImageUploadSuccess(e, key) {
this.item[key] = e.url;
this.save();
}
/**
* 储存音频数据
* @param e
*/
onAudioUploadSuccess(e, key) {
this.item[key] = e.url;
this.save(); this.save();
} }
/** /**
* 储存数据 * 储存数据
*/ */
save() { save() {
(<any> window).courseware.setData(this.item, null, this.saveKey); (<any>window).courseware.setData({ msg: this.msg }, null, this.KEY);
this.refresh(); this.refresh();
} }
/** /**
* 刷新 渲染页面 * 刷新 渲染页面
* 立即执行
*/ */
refresh() { refresh() {
setTimeout(() => { setTimeout(() => {
this.appRef.tick(); this.appRef.tick();
}, 1); }, 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