Yes, that returns some valid JSON.
I can't parse json ajax data
Unexpected token < in JSON at position 80 at JSON.parse ()
funciona bien si le quito la etiqueta "ion-content"
este es mi codigo de mi services
angular.module('app.services', [])
.factory('auth', ['$state', function ($state) {
var auth = {
setToken: function (token) {
localStorage[API.token_name] = token;
},
getToken: function () {
return localStorage[API.token_name];
},
getUserData: function () {
console.log(auth);
try{
var token = localStorage[API.token_name];
if (token === '') return;
var base64Url = token.split('.')[1];
var base64 = base64Url.replace('-', '+').replace('_', '/');
console.log()
return JSON.parse(window.atob(base64)).data;
} catch(err) {
$state.go('signup');
}
},
logout: function () {
localStorage[API.token_name] = '';
$state.go('signup');
},
hasToken: function () {
return (localStorage[API.token_name] !== '');
},
redirectIfNotExists: function () {
if (!auth.hasToken()) {
$state.go('signup');
}
}
};
return auth;
}])
.service('loader', function () {
this.show = function (show) {
document.querySelector("#loader").style.display = show ? 'block' : 'none';
};
})
.service('restApi', ['$http', 'loader', 'auth', function ($http, loader, auth) {
this.call = function (config) {
var headers = {};
headers[API.token_name] = auth.getToken();
loader.show(true);
var http_config = {
method: config.method,
url: API.base_url + config.url,
data: typeof (config.data) === 'undefined' ? null : config.data,
headers: headers
};
$http(http_config).then(function successCallback(response) {
loader.show(false);
config.response(response.data);
}, function errorCallback(response) {
loader.show(false);
switch (response.status) {
case 401: // No autorizado
auth.logout();
break;
case 422: // Validación
config.validationError(response.data);
break;
default:
config.error(response);
console.log(response.statusText);
break;
}
});
};
}])
Loading custom HTML from a file?
I've got some flowcharts built in HTML that work fine in Ionic 1 if you put them in their own html file.
I'm sure they'll work fine in Ionic 2, but each one has it's own HTML page and I don't really want to do this.
I'd like dynamically generate what is in the ion-content tag, with something like {{content.flowchart1}}. The html is just styled divs.
What's the best way to do this?
I can't parse json ajax data
But I can't parse this URL.
Can you try parse this URL?
Loading custom HTML from a file?
You could create a set of variables that contain links to those files then use something like an iframe to display the files.
Edit:
Or you could try this..<object type="text/html" data="mypage.html" ></object>
Can i generate an IPA file with a checked-in[git] folder of ionic 2 platforms folders? Errors says:'www/build/main.js' not found
I am currently working on Ionic 2 project, and i am in need of adding all the files in git, so that other person just have to download the code [need not build the application with : ionic build ios] and just run it. I know adding all platform files to git is not recommended, but currently i need to add it, for a client of mine. When i check-in all files under platforms folder, looks like the it is generating some specific code in my mac, and hence is not able to be run on other mac for the first time. If the other user is adding a new platform, he is able to run it. Other wise with the checked in version of platforms folder, he gets a empty screen in the app, as few folders for www/build/main.js is not available for him. How can i check-in everything to git, so that the other person only has to download [with out need of re-build] and still be able to generate a working IPA file?
Issue with @translate3d in _animations.scss
Its a sidemenu+tabs project....
Instructions followed are as below:
1. Move the SCSS-MOVEME directory up one level and rename it to "scss". This directory should sit side-by-side with the www directory.
Run "npm install" from the working directory of your ionic project (one directory up from www). This will install gulp.js and a few handy tasks, such as gulp-sass and gulp-minify-css.
---- I had issues with npm install. It didn't install any of gulp, gulp-sass or gulp-minify-css.. I had to manually install them individuallyIn the ionic.config.json file, add the JavaScript property
AWS Mobile Hub Starter
Very true!
Is there a write-up on how to pull down these Starter projects and develop them? I cloned and created a branch, but I don't know how to convert the cloned source to an ionic project. After clone, I get:ionic serve can only be run in an Ionic project directory.
Ionic Swipeable Tabs are now here!
If you are using lazy module loading, then you also need to import
SuperTabsModule in the child modules.
Please check existing issues on Github and report and problems there.
I can't parse json ajax data
What is your proxy definition code for the CLI?
AWS Mobile Hub Starter
Run ionic start
for the starter you want and watch the output of the CLI. (It downloads https://github.com/ionic-team/ionic2-app-base first and then installs the starter over it to create a complete working project.)
Ionic printer issue
```
Hi Sujan,
Thanks for your reply.
actually am new to this framework.
My home.html file is
<ion-content padding>
<button (click)="print()">Print</button>
</ion-content>
and my home.ts file is
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Printer, PrintOptions } from '@ionic-native/printer';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController,private printer: Printer) {
}
print()
{
this.printer.isAvailable().then(this.onSuccessLoad, this.onErrorLoad);
}
onSuccessLoad(){
let options: PrintOptions = {
name: 'MyDocument',
printerId: 'My Printer XYZ',
duplex: true,
landscape: true,
grayscale: true
};
this.printer.print("http://google.com",options).then(this.onSuccessPrint,
this.onErrorPrint);
}
onErrorLoad(){
alert('Error : printing is unavailable on your device ');
}
onSuccessPrint(){
alert("printing done successfully !");
}
onErrorPrint(){
alert("Error while printing !");
}
}
i have added this printer in provider also in app.module.ts
so when app get loaded I get print button so when i click on it call print() method.
in print method i have
this.printer.isAvailable().then(this.onSuccessLoad, this.onErrorLoad);
so
it calls this.onErrorLoad method.It means printer is not available.
my onErrorLoad method is
onErrorLoad(){
alert('Error : printing is unavailable on your device ');
}
i want it should call this.onSuccessLoad.
please help me to make printer available so that this.onSuccessLoad can run.
Thanks
`
Using Firebase Cloud Functions in an Ionic application
There are a lot of backend technologies. If you don't to choose and prefer to stick to Javascript without setting up Node.js, you can have a look at Cloud Functions for Firebase and this is what we will use in this tutorial with an Ionic application.
https://www.javascripttuts.com/using-firebase-cloud-functions-in-an-ionic-application/
I can't parse json ajax data
which ionic version you are using? (cli: ionic info)
Give a try on previous version (eg: 3.2.1).
After splash screen, display white screen long time
Error after installing Document Viewer plugin
After I have installed Document Viewer plugin (with ionic 3 project and platform added android) I have this error:
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':mergeDebugResources'.Error: java.util.concurrent.ExecutionException: java.io.IOException: � in corso la chiusura della pipe
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.[ERROR] An error occurred while running cordova run android (exit code 1).
Open a pdf file in ionic
I have tried with Document Viewer plugin but I have this error:
I can't parse json ajax data
IonicBuildAndroidError
could be the problem ?
emulator android==>4.3
ionic android==>6.2.2
Loading custom HTML from a file?
Do I need an iFrame though? Can I not just do what you've done with the <object? tag with an ion-content tag?
I could test this but I'd like to know the best way to start...