Skip to content

Commit

Permalink
fix: toggle case (#13)
Browse files Browse the repository at this point in the history
* style:card hover

* pref:add input params

* pref:add output error message

* fix:modify angular.json

* fix:add maxselect juge

* fix:output message

* fix:css var compatible

* refactor: output message

* fea: matching elements

* doc: update readme

* fix: input params not concat

* fix: toggle case

* fix: resolve conflict
  • Loading branch information
margintopt authored Nov 14, 2018
1 parent a85f3b7 commit 6d896f4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
25 changes: 12 additions & 13 deletions components/periodic-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,25 @@ export class MtaPeriodicTableComponent implements OnInit, OnChanges, OnDestroy
}

ngOnChanges(): void {
this.initCanSelect();
this.canSelectElements = this.canSelectElements.concat(this.service.selectedElements);
this.service.setCanSelectElements(this.canSelectElements);
}

ngOnDestroy(): void {
this.change$.unsubscribe();
}

/**
* 如果不传入或为不为数组,初始化canSelectElements
*/
initCanSelect () {
if (this.canSelectElements === undefined || !(this.canSelectElements instanceof Array)) {
this.canSelectElements = [];
for (const key in this.e) {
if (key) {
this.canSelectElements.push(key);
}
}
} else {
this.canSelectElements = this.canSelectElements.concat(this.service.selectedElements);
const arr = [];
for (const item of this.canSelectElements) {
arr.push(item.toLocaleLowerCase());
}
this.canSelectElements = arr;
}
this.service.setCanSelectElements(this.canSelectElements);
}

ngOnDestroy(): void {
this.change$.unsubscribe();
}
}
14 changes: 4 additions & 10 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,11 @@ export class AppComponent implements OnInit {
ngOnInit(): void {
this.canSelectElements = undefined;
setTimeout( () => {
this.canSelectElements = ['am'];
}, 1000);
this.canSelectElements = ['AM'];
}, 5000);
setTimeout( () => {
this.canSelectElements = ['si'];
}, 2000);
setTimeout( () => {
this.canSelectElements = ['be'];
}, 3000);
setTimeout( () => {
this.canSelectElements = ['he'];
}, 4000);
this.canSelectElements = ['SI'];
}, 10000);
}

aaa(e) {
Expand Down

0 comments on commit 6d896f4

Please sign in to comment.