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() {
......
...@@ -59,10 +59,14 @@ ...@@ -59,10 +59,14 @@
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