Interface for Ionic angular 2 - ionic-framework

Is it recommended to use interface in ionic 2?
Which means is it fine to use interface in ionic 2 or strictly we should not use it. My purpose of using interface in ionic2 is want to create a custom modal in my ionic application.
thanks
AK

I see no reason to not use TypeScript interface in your Ionic project.
It's a standard principle in TypeScript and the whole Ionic Framework is written in TypeScript. At the end it will be compiled to JavaScript anyways.
Here are some resources
https://www.typescriptlang.org/docs/handbook/interfaces.html
https://ionicframework.com/docs/developer-resources/what-is/#typescript

Related

Using ionic to make an app for Androids and iPhones

I've just finished building my website and will deploy it shortly, however I want to make an app and I was hoping to find a way of taking my existing front end code and dump it into ionic and get a nice app out of it.
Is it going to be that simple to make an app using ionic or will I have to rebuild the front end all over again if I'm going to use ionic?
It depends on what you made your site with. If you used a framework compatible with ionic like angular it is fine (see this article: https://levelup.gitconnected.com/converting-angular-web-application-into-ionic-app-5af678325626)
If you have developed in pure Html / css / js you can always reuse part of your code but you will need to import it in a framework (React, Vue or Angular)

How to drag elements in Ionic 4/5

I would like to create draggable (free) buttons in Ionic. In ionic 3 I used a directive to do this (link https://www.joshmorony.com/building-an-absolute-drag-directive-in-ionic-2/) but this directive don't works in ionic 5 and it does not give any errors. What do you think is the best library (supported from some tutorial) for ionic 5 to do this? Thanks in advance.
This does not have to be Ionic specific. If you are using angular you can just use an NPM component such as https://www.npmjs.com/package/angular-draggable-droppable
There is also support for this in Angular Material library
https://material.angular.io/cdk/drag-drop/overview

Adding ionic pages to already created Angular app [ionic]

I've successfully converted the angular app into an ionic app which can run on iOS and Android. Now I am trying to grab the lifecycle methods (ionViewDidLoad, ionviewdidleave, etc) when the components appear/disappear. The app currently does not have any ionic pages, do I need to add a page(s) to get these lifecycle methods? I've been doing ionic for a week or so, so please keep the flame on low.
Thanks
Ionic 4 has deprecated the previous IonicPage and its navigation. It now uses the default navigation of the template you are using. In case of angular its angular router
Previous versions of Ionic shipped with our own custom router, but in order to provide the best tooling and developer experience we have since moved to using the framework's recommended router.
Ionic 4 provides the hooks:
ionViewWillEnter, ionViewDidEnter, ionViewWillLeave, and ionViewDidLeave
Also check migration guide here.
You can use the angular lifecycle hooks in place of the older ionic lifecycle hooks like ngOnInit in place of ionViewDidLoad. Use angular's router guard instead of ionic's navguard.

Is there a way to get Ionic components without Angular?

I want to build an app with Ionic and VueJS, and I want to get Ionic components working in Vanilla JS, is there any library or resource to do that?
This will be possible in the near-future with Ionic 4. Their framework will soon be framework agnostic, which means it will be usable with any JS framework or even plain JS. You can read all about it on the official blog post of Ionic.
Here's an excerpt of the article:
For those that love Ionic but want to use it with Vue, or React, or Ember, or jQuery, or plain JavaScript, you’ll be able to once Ionic 4 releases.

What makes nativescript better than ionic

im new to mobile development and i see ionic framework has very big community BUT
i know that ionic uses webview while nativescript generates native components
my question now what nativescript can do ionic cannot do?
in other words what is the powerful points in nativescript that does not exists in ionic
thanks in advance.
Ionic is hybrid, running inside webview which has problem with performance at particular things like even simpler animation, not fully accessible API of native part
Nativescript runs as native app, controlled by JS code but can be used even with native code or even as addon to native app and full access to API of native code