Ionic Cordova AngularJS

Having heard of an AngularJS mobile phone system that transmits data back to a server, I decided I ought to investigate.
The prompt for this was working with web services on the Media Library Database.

10-May-2018 - At last! One last push on this problematic http post
Turns out that the fix for this is fairly straightforward, but you have to know otherwise it'll never work, so here it is...
In order to access an external web site, the app needs to have the base url specified in the index.html (or other main page).
In my call to $http.post, I have this as the url:
var url = 'http://192.168.1.80:8081/api/products/PostToDoList?data=' + data;
For the app to gain access from the mobile phone, it needs this in the main page:
<meta http-equiv="Content-Security-Policy" content="default-src 'self' http://192.168.1.80:8081/api/">

08-May-2018 - Added Web Api to send data from phone to a listener on my pc. Works in the Ionic lab, but not on the phone.
Tried everything, CORS enabled, nothing matching on internet search, so am a tab stumped!
Leaving as-is for now - will look into WebAPI on Media Library...

04-May-2018 - Added Ok to delete? dialog. Working and deployed to my mobile phone.
Has the world gone mad? If you search for something like 'angularjs confirm delete dialog', then what usually pops up is along the lines of:
  • Using a different ng directive...
  • ...add an extension to an event handler...
  • ...pass in the function that should be called if ok to continue...
  • ...add an app directive that is the extension.
The reasoning behind this approach is that, becuase it used injection, it can be easier to wrap a test harness around it.
However, there is nothing on-line I have found that deals with a parameter that needs to be passed to the destination function.
So, back to basics...this was the original code:
$scope.removeTask = function (index) {
	//removes a task
	$scope.tasks.splice(index, 1);
	localStorageService.set(taskData, $scope.tasks);
};
...and I changed it to this, which works and is readable:
$scope.removeTask = function (index) {
	if (okToDelete())
	{
		//removes a task
		$scope.tasks.splice(index, 1);
		localStorageService.set(taskData, $scope.tasks);
	}
};

function okToDelete() {
	return confirm("Ok to delete?");
}
03-May-2018 - Added Update option. Working and deployed to my mobile phone.
02-May-2018 - Working and deployed to my mobile phone.
The local storage problem was nothing to do with the browser - the sample code was a tad buggy and had one of the data items incorrectly initalised.
Took a bit of trial and error - had it running in the Ionic Lab ok but not working on the phone.
After a few attempts, got the data initalised correctly and added my icons.
Installable apk file copied to phone and installed = all working :-)

01-May-2018 - So, now on Ionic 2, Win 64 Android 26.
  • Built and deployed apk :-)
  • App not storing data - sometimes it does :-(
  • Web searching suggests a problem with local storage, but that's only of one version of one browser.
30-Apr-2018 - Recap - I've been using Ionic 1 on Win 32.
The JDK for Win32 is only available as a zip with no install, so a complete pain in the ar** to set up correctly.
So, after 8 hours, can test run, but not build an apk = executive decision, switch to Ionic 2 and Win64.
Oh, joy, up and running in no time.

29-Apr-2018 - After searching the web, I went for a simple example that stores data in the local storeage using Ionic/Cordova/AngularJS.
Head banging time! A day wasted!? no, a lesson learnt. Following an online tutorial:
  • Installed Node to get NodeJS and npm;
  • Installed JRE and JDK;
  • Installed Ionic and Cordova;
  • Created new Ionic project;
  • Added sample code;
  • Build and run - didn't work!!!!

© 2018 - StartledCat