Greetings I need to send and receive data by FM radio signal
Send data to fm
Correct way to handle asynchronous call & return in Typescript
Thanks for your reply.
With your solution the service is just calling the request, and sending the result to the page.
But what if i want to do some stuff about the data in my service before sending back the result to the page ?
Like:
- The page call the service function
- the service make the request, and got a reply
- the service do stuff (populating the app with the datas per example)
- then it send a string back to the page , like “job is done”
Thanks again
Correct way to handle asynchronous call & return in Typescript
Hi
I suggest going through the Tour of Heroes on angular.io. Will help a lot on everything related to ionic, angular, typescript, rxjs etc.
Other info: https://angular.io/guide/http
https://angular.io/guide/observables
You should use RXJS operators to work on the datastream (using pipe). And return the resulting observable to the page that subscribes to it.
Example: https://www.concretepage.com/angular/angular-rxjs-filter
Firebase storage on Ionic 4
Angularfire:
Web sdk:
https://firebase.google.com/docs/storage/web/upload-files
FCM onNotification only works when app is in background
No, I ended up removing FCM and just using Google plugin.
Alternatives to Infinitescroll
What are the alternative methods to InfiniteScroll for paging results from an API?
CORS ISSUE - IONIC 5 Cordova 9 - web api PHP
+10!
Drowning pool lyrics will now never be the same for me!
@rapropos - I must admit to seeing CORS issue, and had a snippet to “make it work”.
I completely agree, use the functionality provided if possible and avoid pitfalls and un-knows.
Firebase storage on Ionic 4
Sure.
The docs are in PDF format, which we all know to be unilaterally available to all. The client wanted a horizontal “slide show” of those PDF docs. I was working with Ionic’s ion-slide as I have done on other projects. I have NOT (yet) been able to use any PDF utility inside of the component. I have not given up on that and also looking at showing a single PDF with Back and Fwd buttons. I have been working with the ng2-pdf which I know works fine for displaying single PDF. Not done with this subject.
Correct way to handle asynchronous call & return in Typescript
I found the solution
/**
* Fetch the Sim_Agents from the Simulation_orchestrator in order to populate the app
* */
async Get_Sim_Agents() : Promise<string>{
return this.http.get(
"http://" +
this.simulation_orchestrator_ip_address +
":" +
this.simulation_orchestrator_port +
"/get_sim_agents"
).toPromise().then(response => {
var data = JSON.stringify(response, null, 2);
// here i do some stuff about the data
return JSON.parse(data);
});
}
How to hide an ion-back-button for lg and xl screens
I managed to do what I needed to with angular flex-layout.
It is a great library. In case I stupidly missed an abvious one with ionic please let me know. Otherwise, I hope this helps someone else in the future.
[formControlName] not working
Because when you put it in brackets, the Angular compiler says to itself “I need to find a property with that name in the controller”, and when it doesn’t find one, it gets cranky. When you take the brackets off, the Angular compiler DGAF any more about the fact that you spelled “form” as “from”.
Correct way to handle asynchronous call & return in Typescript
Surely gets this month’s reward for funniest anti pattern. First time I have seen this meshup of observables and promises
But hey, if it works for you, why care!
TO get and put the data from and to database in Ionic without Angluar core such as ngmodels?
Yes.
I, personally, have neither the resources, time, nor ability to make a framework like Angular. Unless (and arguably even if) you do, I really think you would be better off in even the short term spending the time you would be taking trying to make one on learning Angular (or React, if you prefer).
You would want to write a service that responds to HTTP requests to REST endpoints and interacts with that database. If you’re mentioning PHPMyAdmin, I guess that means you would probably select PHP for that task. On the client side, you would have to find or write a service that makes XMLHttpRequests to it. Well, that is, after you’ve written the event handling part of your framework.
I’m not sure what you mean by “normal” here, but if you’re already writing web apps in whatever manner you consider “normal”, and you’re basically asking if you can use Ionic as a glorified mobile-first sort of UI toolkit, the answer is still an emphatic “yes”, although I would still urge you strongly to rethink your opposition to using an established framework.
Correct way to handle asynchronous call & return in Typescript
The only reason this even compiles is part of why I keep harping on people that pollute their own code with any
.
JSON.parse
is returning an object. It doesn’t know the type of said object, so it’s declared as any
. It is definitely not a string
, so callers of this function are going to be surprised with what they get.
You shouldn’t even be calling JSON.anything, though.
Angular’s HttpClient
knows that 95% of the time, it’s being used as you are here, to sling objects around. It takes a template parameter, so the way I would write this is more like so:
interface SimAgentWired {
id: string;
// whatever other stuff comes over the wire from the raw HTTP response
}
// this is the form we work with in the app
export interface SimAgent {
id: string;
rank: number;
name: string;
// &c
}
private unwireSimAgent(wsa: SimAgentWired): SimAgent {
// here you do some stuff about a single agent
}
allSimAgents(): Observable<SimAgent[]> {
return this.http.get<SimAgentWired[]>.pipe(
map(wsas => wsas.map(wsa => this.unwireSimAgent(wsa)));
}
Now you get all the benefits of strict type checking throughout, you can massage each SimAgent
as necessary.
How to fix spacing issue with variable slide heights using ion-slides?
you solve this in ionic 4 in sliders options in your .ts file putting parameter autoheight=true
slideOpts = {
autoHeight: true
};
hope that help!
Focus is not pointing to first input
Thirdly, setTimeout
, especially with magic numbers, is virtually always papering over an existing race condition. Don’t do it. Fix the underlying issue instead.
Bkg-img path on a scss file?
thanks. Close the Ionic Studio, and reopened… then it worked.
How is the ion-nav done in ionic 4?
I would like to know how to implement the in my project since in the documentation they do not give almost information
USB serial not showing all the data
Hello everyone from the forums! I am having extreme issues with this as I’ve spent an entire day browsing for solutions and I’ve come up with nothing that can solve my issue, I’m conecting my tablet through USB serial cable, and the thing that’s sending data to me is sending (working on Ionic 4):
Now, when I try to retrieve it from my code like this:
My HTML:
<ion-button expand="block" (click)="beginReading()">ReadSerial</ion-button>
<p> WHAT I'M READING IS: {{SERIALREAD}}</p>
And in my .ts I have((sorry for the spanish beforehand)):
checkearSerial() {
this.serial.requestPermission().then(() => {
this.serial.open({
baudRate: 9600,
dataBits: 8,
stopBits: 1,
parity: 0,
dtr: false,
rts: false,
sleepOnPause: false
}).then(() => {
this.ESTADOCONSERIAL = 'conexion realizada'
console.log('Serial connection opened');
this.localNotifications.schedule({
id: 2,
title: 'ALERTA',
text: 'USB ENCONTRADO',
data: { mydata: 'BLAHBLAH' },
trigger: { in: 1, unit: ELocalNotificationTriggerUnit.SECOND },
foreground: true
});
});
}).catch((error: any) => {
this.ERRORSERIAL = error
this.ESTADOCONSERIAL = "no conectado"
});
}
And:
empezarLectura() {
if (this.lector) {
this.lector.unsubscribe();
}
else {
this.lector = timer(1000, 1000).subscribe(() => {
this.serial.registerReadCallback().subscribe(val => {
var view = new Uint8Array(val);
var str = String.fromCharCode.apply(null, view);
this.SERIALREAD = str
})
})
}
}
I’ve come into the necessity to use the subscribeable variable “lector” as the registerCallback function kinda just does the thing once and then just stops.
Anyways, my problem is that when I display the data, it is -NEVER- complete, taking the example image from before, it would print stuff like:
-AD:30
-ETRO:12
-003
-VELOCI
ETC. I NEVER get the entire data… please, help me out with this, I’m dying at work ;-; I can provide additional information if asked
How is the ion-nav done in ionic 4?
Hi
The Routing & Navigation concept has changed from Ionic 3 to 4.
If you use for example Ionic with Angular, Ionic is using directly the Angular-Router:
https://angular.io/guide/router
Ionic-Docs:
- Angular implementation: https://ionicframework.com/docs/angular/navigation
- React implementation: https://ionicframework.com/docs/react/navigation