AngularJS + PhoneGap - javascript

I'm hopeful this issue has already been approached. Does PhoneGap work with AngularJS? Are there any limitations to using them together? Benefits/pitfals? Thanks

Yes.
I have made multiple applications with PhoneGap plus AngularJS. There's no magic to it.

PhoneGap just runs your application within the native device browser, so if AngularJS is supported on your target platforms, it should work with PhoneGap.

I'm having trouble getting angularjs working on windows phone 7 with phonegap. The simple stiff works, but as soon as I try to add page route...
[Edit]
Ok. So I have found the problem on windows phone 7/8.
in the function matchUrl(url,obj) in angular.js (1.0.3) there is a regex that fails because Windows Phone use an unusual prefix or namespace or whatever it is called (probably for security purposes).
What happens is angular is expecting a url like 'http://localhost/www/index.html' but in windows phone it will look like: 'x-wmapp0:www/index.html' instead.
I tried fixing the regex, but even so I get an error later on from XHR.

I've found that the brian t ford article (which everyone references) doesn't really explain how the config file is picked up (which includes the pointer to the index.html file and several other assets) which marks it out as a little out of date. It would be great to get a good update on it.

I am currently working on a project with Phonegap and AngularJS. I do recommend the following reading. Will help you decide if it's what you want in an hour.
http://briantford.com/blog/angular-phonegap.html
AngularJs will let you have the power and structure of a website but it has a small flaw is that it is a bit slow, I say this from experience and it happens that sometimes the models take a while to cool off.
Likewise, I recommend that you take a look at Yeomen, I am currently working on a generator angularJS phonegap and hope to have it for this weekend.
regards
#gartox

Yes. http://ionicframework.com is a framework that integrated Cordova and AngularJS. It will save you a lot of time trying to get everything set up.
To install the framework:
npm install -g cordova ionic
To create new empty:
ionic start myApp blank
All the options available in phonegap are also available in Ionic. For example, you could type
ionic serve
And your mobile app will open right in the browser, and auto-update whenever new changes are made to the files, just like in Phonegap.

From PhoneGap's blog:
http://phonegap.com/blog/2013/07/31/phonegap-30-faq/
Q: Does PhoneGap play well with angular.js? Or any other framework?
A: It sure does. PhoneGap does not dictate how an app gets authored with HTML, CSS, and JavaScript. We play nice with all frameworks and, of late, many are being authored today with Angular.

Related

Nativescript core OCR plugin

I'm trying to develop an ocr app with the Nativescript plugin:
https://market.nativescript.org/plugins/nativescript-ocr
https://github.com/EddyVerbruggen/nativescript-ocr
and it seems that the example doesn't works or I'm doing something wrong. I read something about Firebase ML kit but I have no idea about that and if it works offline (Offline work is a must for me).
https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/master/docs/ML_KIT.md
Could be deprecated the first plugin?
might I use firebase?
could it use with nativescript core (only js)?
It works offline?
Any idea about how to start?
Yes, the OCR plugin is kind of deprecated, not actively maintained anymore.
Firebase ML-Kit is recommended and it has different methods you could use for text recognition, one works on device and another on cloud. Refer the same read me you have linked in your question.

How to use server-side rendering in Angular 2?

I have a web app developed with Angular 2 which communicates with Java APIs on the server to fetch data. Everything is working fine except the pages are not indexed by search engine (except Google which supports script generated tags).
I've googled a lot and found that this can be achieved by "server side rendering" and there are libraries available to achieve this but all of these are commercial products that require payment.
I have come across Angular Universal which is not a commercial product, can we use it to solve our issue? If it can then how can we hook it up to our existing app?
You are on the right path there are two ways to achieve your objective
If you are using #angular/cli for developing angular app then you can only follow this link
If you developing with your own webpack.config file then there are lot of options available, best of them is universal-starter , which is featued in official documentation of angular/universal
While continuing with #angular/cli, there is a little caveat that it doesn't support lazy loading yet but they are working on it and future is bright with #angular/cli. If you want to implement lazy loading now only then i will suggest you go ahead with second option.

How do I go about creating a javascript ipad app that uses local storage?

I need to create an internal admin app. The app needs to be able to:
For V1
- Wrap and execute javascript code
- Will not rely on any iOS code other than perhaps the code necessary to load the javascript.
- Uses local storage
For V2
- Work offline (which means javascript code needs to be loaded in)
Any ideas on how to go about implementing such a thing?
By far the easiest and best supported way is to use Apache Cordova. They did all the work of wrapping a Webview in a native app and have a rich set of plugins for integration with all kinds of mobile APIs.
Since the app will be running in an embedded browser you can simply access the normal Localstorage APIs.
The Cordova tutorial by #ccoenraets may be a good way to get started.
From my findings the following two are great solutions:
Ionic
Apache Cordova

IOAuth.IO Integration with Ionic/Angular Hybrid App

I am having a really difficult time getting the cordova plugin authored by OAuth.io (https://github.com/oauth-io/oauth-phonegap) to work within the an ionic phone build. Everything is setup based off of the desktop version of the JS file they provide, wrapped in an Angular service for ease of unit testing, with another factory handling the actual flow of login/logout etc...
The issue I am running into is that now after switching to the plugin version and removing the referenced JS version, nothing works any longer. I can no longer pull up the facebook login page, nor have the global object 'OAuth' recognized outside of the injected service. The furthest I got in troubleshooting the issue is that the OAuth object is created, at least initially as I can log out the object, but anything after that does not appear to be recognized.
My web (working) version of code example is on plunker here: http://plnkr.co/edit/B4HdkkBKDP3Xv2riQGui?p=preview
Any thoughts on further troubleshooting or if there is another way of accomplishing this goal would be greatly appreciated!
We just published the version 0.2.0 of the OAuth.io Cordova/Phonegap SDK, which fixes the issue with Ionic.
Now you should be able to use the cordova plugin in a ionic app without any trouble, like this:
$ cordova plugin add https://github.com/oauth-io/oauth-phonegap
This version also contains features that were missing from the sdk, like the cache and the unified user info method.
You can get more information about all this on our github page:
https://github.com/oauth-io/oauth-phonegap
Hope this helps :)

Change device profile using phonegap / cordova

Iam using PhoneGap/Cordova + Backbone for developing a cross platform mobile application. Using phonegap i can access almost all the functions of the device. Is there somehow possible to access or change the device's profile using PhoneGap or using backbone ? I searched a lot but couldn't find any relevant results..!!
Is there any documentation available on this ?
Any help will be very much appreciated..!!
I didnt get what you means about "device's profile". You talking about accounts?
About Phonegap/Cordova you can do everything that a native app can. But sometimes you need to write a native plugin to interact with device. I already had to do that to do push notifications using a third lib.
You write a native class to do something, register it in plugins, give permissions and then call it with your javascript.
You can find documentation here: http://cordova.apache.org/docs/en/3.4.0/guide_hybrid_plugins_index.md.html#Plugin%20Development%20Guide
Add this cordova plugin into your project.
https://github.com/apache/cordova-plugin-device
Put these line of codes into your view page
alert(device.cordova);
alert(device.model);
alert(device.name);
alert(device.platform);
alert(device.uuid);
alert(device.version);

Categories