Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {Page} from 'ionic-angular';
- import {BLE} from 'ionic-native';
- @Page({
- templateUrl: 'build/pages/list/list.html'
- })
- export class ListPage {
- devices: Array<{name:string, id: string}>;
- constructor() {
- this.devices=[];
- }
- startScan (){
- this.devices = []; // This "this" exists and works fine
- BLE.scan([],5).subscribe(
- (device)=>{
- if(device.name){
- this.devices.push({name:device.name,id:device.id}); // this.devices does not exists
- }
- },
- (err) => {
- console.log(JSON.stringify(err));
- }
- );
- }
- connectToDevice(device){
- BLE.connect(device.id).subscribe(success=>{
- console.log(JSON.stringify(success));
- });
- }
- }
- var self = this;
- startScan = () => {
- this.devices = [];
- BLE.scan([],5).subscribe(
- (device)=>{
- if(device.name){
- this.devices.push({name:device.name,id:device.id}); // this.devices does not exists
- }
- },
- (err) => {
- console.log(JSON.stringify(err));
- }
- );
- }
- <div class="console-display">
- <textarea [(ngModel)]="textAreaContent" name="mainText"></textarea>
- <div class="console-keys">
- <button (click)="getKeyInput($event)" name="key01" type="button" value="1">1</button>
- <button (click)="getKeyInput($event)" name="key02" type="button" value="2">2</button>
- </div>
- </div>
- export class HomeComponent {
- tempString = "64";
- getKeyInput(event){
- let self = this;
- manageTextArea(self, event.target.value, this.textAreaContent);
- }
- }
- function manageTextArea(self , ch : string, textArea : string): void {
- if (checkCharacter_Number(ch)){
- self.textAreaContent += ch;
- }
- console.log(self.tempString);
- }
Add Comment
Please, Sign In to add comment