Phonegap with page.js routes works only on desktop - javascript

I am using page.js in an HTML+CSS+JS app.
The routes work perfectly in browser, even using the "phonegap serve" and accessing my_ip:3000.
But when I try to load it in my phoneGap Developer (in an Android phone), only the first route loads (if I try to navigate through the app links, I get only blank screens).

When using page.js in mobile apps (with cordova, phonegap or cocoon), just use:
page( { dispatch: false } )
page( '/' )
Instead of:
page()
You can replace '/' with the first route that you want your app to start with.
In details:
Normally, in a web app, you use page() to start the routing process and, of course, it will identify which route is being requested and call the correspondent function.
Since in mobile we don't have an URL request, we disable this identification process with dispatch: false and pass a default start route.

Related

unable route to pages after doing build and deployed in aws instance using angular

here in my local my application is working and previously the build edition used to run in docker also but when we moved to aws the issue we arised is some url and not navigating when we try to navigate i am getting
the link is this http://www.sometesturl/demo-page
and other routing url are working and it is like i declared like
on clicking it has to redirect and like this i have 7 other pages which are working but only this page is not working and i applied
RouterModule.forRoot(
appRoutes,
{ enableTracing: true,useHash:true,anchorScrolling:'enabled' } // <-- debugging purposes only
)
useHash:True also but whats happening is then the url stays in the same page i mean if click on the demo page then it redirects and come back to the same page again like http://www.sometesturl/#/ to http://www.sometesturl/demo-page to http://www.sometesturl/#/ it even doesn't redirect also if i use Hash is there any config rules to be written for aws instance

Link from external page to ember route

I have an Ember app which is run using engines (So there are other apps as well)
In my app, I have the following route defined in addon\routes.js
this.route('my-route');
My question is, say from some other app (which does not use Ember), can I have the following link called as say href of an anchor tag
OR browser redirect & it would deep route to where I want ?
https://abc.xyz.com/xyz/123/ui/#/myapp/my-route?action=123
I ultimately hope to get the control in my-route (after the other app hits the above URL)

window.location.href not working in mobile device in an ionic app

I am trying to open a view with a function call from UI side
<ion-option-button class="button-light icon ion-chatbubble" ng-click="openView('username')"></ion-option-button>
the controller code for the same is
$scope.openView=function(user){
window.location.href ="/signin.html#/im?p=#"+user;
};
Now this works perfectly in the browser but when I test this in mobile device I get the following error :-
ERR_FILE_NOT_FOUND(file:///signin.html#im?p=username)
I know there are multiple ways and preferably one should use ui router etc but I have load the view of another angular app inside my app that is why I am somehow stuck on this.
path on ionic should be relative, remove leading slash and try:
window.location.href ="signin.html#/im?p=#"+user;
$scope.openView=function(user){
$state.go('app.signin');
};
and $state defined in your controller.

Use PhantomJS to make my angular app crawlable

I am trying to use PhantomJS and angular-seo (https://github.com/steeve/angular-seo) to make my app crawlable.
As I am not using hashbangs, I've added the following meta tag to my app's header:
<meta name="fragment" content="!" />
In my main controller, I trigger $scope.htmlReady when the content is fully loaded:
$scope.$on('$viewContentLoaded', function() {
$scope.htmlReady();
});
I have loaded the seo module properly and while my server's app listens on port 4000 (I use an express server), I launch phantomJS on port 4040 with the following command:
phantomjs --disk-cache=no ./bin/angular-seo-server.js 4040 http://127.0.0.1:4000
If I check how things are working for the homepage with a simple curl 'http://127.0.0.1:4040/?_escaped_fragment_=' I get the correct HTML rendered properly.
But if I try a different route like http://127.0.0.1:4040/test?_escaped_fragment_= I only get <html><head></head><body></body></html> while http://127.0.0.1:4000/test works fine.
How can I make sure all my pages are indexed and not only my homepage?

Backbone - copy paste url

I've created a small website by using backbone.js. It's hosted in IIS 7.
The routing:
routes: {
"/": "index",
"": "index",
"detailedpage/:id": "detailedpage",
'*notFound': 'index'
}
I've a problem when I try to copy/paste an url.
If I want to access directly to
http://www.anydomain.com/detailedpage/1234
it's not working. I can see in the developper tools an internal server error for 1234, path "/detailedpage".
The strange thing is if I access first to
http://www.anydomain.com/
and after copy/paste the url
http://www.anydomain.com/detailedpage/1234
it's working.
Can you please tell me if I need to enable/disable any handler in IIS?
Thank you!
Since backbone is doing the routing, your browser has to have the right content before its loaded. If you wish to use pushState with Backbone, you have to trick your webserver into serving the same html page for all possible routes. The way we do that in IIS is have the .NET routing setup in such a way that loads the required backbone assets so it can do routing directly.
Alternatively, you can disable pushState in Backbone.history.start() and use hash based routing. (myurl/#/myroute)
These are client routes, so you begin with a #.
http://www.anydomain.com/#detailedpage/1234
Include a hashtag is not a solution. It's just tell to the browser what is the root url.
The root cause is probably the redirection to the index page which is not correctly working.
The solution I did is to put the html into a view in a MVC application. All requests are redirect to the same controller, which return this new view. So I'm sure that all request are redirect to the index page.

Categories