Commit 29d0fc7d authored by liujiangnan's avatar liujiangnan

修改展现问题

parent c1ca728f
import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output} from '@angular/core'; import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef} from '@angular/core';
import * as _ from 'lodash'; import * as _ from 'lodash';
@Component({ @Component({
...@@ -24,25 +24,22 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -24,25 +24,22 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
teststr = ""; teststr = "";
constructor() { constructor(private appRef: ApplicationRef) {
} }
ngOnInit() { ngOnInit() {
var _this = this; let _this = this;
setTimeout(()=>{ (<any>window).courseware.getData(function(data){
this.titleObj.content = "Hello world!!!"; if(data){
this.teststr = "************" _this.titleObj = data;
},2000); _this.appRef.tick();
// (<any>window).courseware.getData(function(data){ }
// if(data){ });
// _this.titleObj.content = data.content;
// } }
// });
}
ngOnChanges() { ngOnChanges() {
} }
ngOnDestroy() { ngOnDestroy() {
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
} }
}); });
}, },
setData: function(data,callback){ setData: function(data,callback){
let str = JSON.stringify(data); let str = JSON.stringify(data);
net.getData("setCoursewareData",{id: id,data: str},function(res){ net.getData("setCoursewareData",{id: id,data: str},function(res){
if(res){ if(res){
...@@ -58,11 +58,15 @@ ...@@ -58,11 +58,15 @@
} else { } else {
return { return {
getData: function(callback){ getData: function(callback){
let data = localStorage.getItem("courseware_data"); let data = localStorage.getItem("courseware_data");
if(data){
data = JSON.parse(data);
}
callback&&callback(data); callback&&callback(data);
}, },
setData: function(data,callback){ setData: function(data,callback){
localStorage.setItem("courseware_data",data); console.log("******local********");
localStorage.setItem("courseware_data",JSON.stringify(data));
callback&&callback(); callback&&callback();
} }
} }
......
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