Guest User

Untitled

a guest
Jan 17th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. import {Page} from 'ionic-angular';
  2. import {BLE} from 'ionic-native';
  3.  
  4. @Page({
  5. templateUrl: 'build/pages/list/list.html'
  6. })
  7. export class ListPage {
  8. devices: Array<{name:string, id: string}>;
  9.  
  10. constructor() {
  11. this.devices=[];
  12. }
  13. startScan (){
  14. this.devices = []; // This "this" exists and works fine
  15. BLE.scan([],5).subscribe(
  16. (device)=>{
  17. if(device.name){
  18. this.devices.push({name:device.name,id:device.id}); // this.devices does not exists
  19. }
  20. },
  21. (err) => {
  22. console.log(JSON.stringify(err));
  23. }
  24. );
  25. }
  26.  
  27. connectToDevice(device){
  28. BLE.connect(device.id).subscribe(success=>{
  29. console.log(JSON.stringify(success));
  30. });
  31. }
  32. }
  33.  
  34. var self = this;
  35.  
  36. startScan = () => {
  37. this.devices = [];
  38. BLE.scan([],5).subscribe(
  39. (device)=>{
  40. if(device.name){
  41. this.devices.push({name:device.name,id:device.id}); // this.devices does not exists
  42. }
  43. },
  44. (err) => {
  45. console.log(JSON.stringify(err));
  46. }
  47. );
  48. }
  49.  
  50. <div class="console-display">
  51. <textarea [(ngModel)]="textAreaContent" name="mainText"></textarea>
  52. <div class="console-keys">
  53. <button (click)="getKeyInput($event)" name="key01" type="button" value="1">1</button>
  54. <button (click)="getKeyInput($event)" name="key02" type="button" value="2">2</button>
  55. </div>
  56. </div>
  57.  
  58. export class HomeComponent {
  59. tempString = "64";
  60. getKeyInput(event){
  61. let self = this;
  62. manageTextArea(self, event.target.value, this.textAreaContent);
  63. }
  64. }
  65.  
  66. function manageTextArea(self , ch : string, textArea : string): void {
  67. if (checkCharacter_Number(ch)){
  68. self.textAreaContent += ch;
  69. }
  70. console.log(self.tempString);
  71. }
Add Comment
Please, Sign In to add comment