Commit 2f13b8eb authored by 范雪寒's avatar 范雪寒

feat: select控件测试

parent 8a51c964
...@@ -128,5 +128,8 @@ ...@@ -128,5 +128,8 @@
} }
} }
}, },
"defaultProject": "ng-template-generator" "defaultProject": "ng-template-generator",
} "cli": {
"analytics": false
}
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
<div class="model-content"> <div class="model-content">
<div style="margin-left: 100px; margin-top: 100px; border-style: double; border-width: 1px; width:400px">
<div *ngFor="let test of item.testList; let i = index">
<div style="position: absolute; left: 200px; top: 100px; width: 800px;"> <div style="margin:20px; width: 350px; border-style: double; border-width: 1px;">
<nz-select style="width: 200px; margin-top: 10px; margin-left: 10px; margin-bottom: 10px;"
<input type="text" nz-input [(ngModel)]="item.text" (blur)="save()"> [(ngModel)]="test.data" (ngModelChange)="save()">
<nz-option nzValue="1" nzLabel="1"></nz-option>
<app-upload-image-with-preview <nz-option nzValue="2" nzLabel="2"></nz-option>
[picUrl]="item.pic_url" </nz-select>
(imageUploaded)="onImageUploadSuccess($event, 'pic_url')" </div>
></app-upload-image-with-preview> </div>
</div>
<app-audio-recorder </div>
[audioUrl]="item.audio_url" \ No newline at end of file
(audioUploaded)="onAudioUploadSuccess($event, 'audio_url')"
></app-audio-recorder>
<app-custom-hot-zone></app-custom-hot-zone>
<app-upload-video></app-upload-video>
<app-lesson-title-config></app-lesson-title-config>
</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';
@Component({ @Component({
selector: 'app-form', selector: 'app-form',
...@@ -10,22 +8,26 @@ import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, Ap ...@@ -10,22 +8,26 @@ import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, Ap
export class FormComponent implements OnInit, OnChanges, OnDestroy { export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存数据用 // 储存数据用
saveKey = "test_0011"; saveKey = "test_01011";
// 储存对象 // 储存对象
item; item;
constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) { }
constructor(private appRef: ApplicationRef,private changeDetectorRef: ChangeDetectorRef) {
}
ngOnInit() { ngOnInit() {
this.item = {}; this.item = {
testList: [
{ data: 0 },
{ data: 1 },
{ data: 2 },
{ data: 3 },
{ data: 4 },
]
};
// 获取存储的数据 // 获取存储的数据
(<any> window).courseware.getData((data) => { (<any>window).courseware.getData((data) => {
if (data) { if (data) {
this.item = data; this.item = data;
...@@ -40,47 +42,30 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -40,47 +42,30 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
ngOnChanges() { ngOnChanges() {
} }
ngOnDestroy() { ngOnDestroy() {
} }
init() { init() {
} }
/** /**
* 储存图片数据 * 储存图片数据
* @param e * @param e
*/ */
onImageUploadSuccess(e, key) { onImageUploadSuccess(e, key) {
this.item[key] = e.url;
this.save();
}
/**
* 储存音频数据
* @param e
*/
onAudioUploadSuccess(e, key) {
this.item[key] = e.url; this.item[key] = e.url;
this.save(); this.save();
} }
/** /**
* 储存数据 * 储存数据
*/ */
save() { save() {
(<any> window).courseware.setData(this.item, null, this.saveKey); (<any>window).courseware.setData(this.item, null, this.saveKey);
this.refresh(); this.refresh();
} }
...@@ -92,6 +77,5 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -92,6 +77,5 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.appRef.tick(); this.appRef.tick();
}, 1); }, 1);
} }
} }
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