AngularJS app accessed from file:// protocol - angularjs

I'm working on an AngularJS app that will have a hosted version and one that can be downloaded. The downloaded version should be accessible with 'file' protocol.
I've encountered several issues when trying to accomplish this. And have overcome quite a bit.
One issue that I am struggling with is enabling html5Mode on the hosted version, while disabling it on the downloaded file version.
Is it possible to set html5Mode based on what location protocol is being used?

I'm fairly sure that HTML5's pushState does not work when using the file:// protocol. For example, it can be used fairly trivially as a phishing vector to try to point to something innocuous (or the other extreme: harmful).
Doesn't it make more sense to package the application into a "runner" of some sort? Even a Chrome application would be easier to handle app updates.

Related

Does UWP app support ajax?

I have a windows 8 hybrid app and now I want to migrate it to UWP. I am facing two issues and I have been searching on the internet for quite a few time. I want to know if UWP support ajax function. Also my anchor tag in href is not parsing. What might be the reason.
I want to know if UWP support ajax function
The answer is yes, you can use ajax in UWP Application. But there are a few things you need to notice when using ajax in UWP.
If you are using ajax to get data from a remote server, please make sure the Internet(Client) capability is enabled in package.appmanifest. If you also want to call ajax from local server, make sure the Private Networks(Client & Server) capability is enabled.
If you are using a Content Security Policy in your app. Make sure the server address of your ajax call is included after default-src or connect-src in <meta>. For details about CSP you can refer to this document.
Cross-Origin should also under your concern when migrating. For enable CORS you can refer to add CORS support to server.
my anchor tag in href is not parsing. What might be the reason.
For safty reason, UWP doesn't support inline javascript. So codes like <a ng-click="jsfunc();"></a> won't work. Please add eventListener in JS files.

Should I use Angular for a local only NW.js project?

I want to build a mid-size application using NodeJS and NW.js (formerly known as node-webkit). The application will grab some data from the internet but isn't talking with one special service which is under my control.
Is it a good idea to use AngularJS nevertheless or is the MVC approach of Angular oversized if there isn't neither a database nor a webservice on the controller layer?
I think Angular would be really fine for databinding and GUI handling, but I'm not sure if it's the right approach for this kind of application.
I see no reason not to use Angular in an nwjs project. I do it myself in the app I just finished building. It's a local-only deck tracking app for hearthstone that never communicates over the internet at runtime. It only ever monitors a log file that is generated by the Hearthstone game. Since the way I'm display information to the user is still technically a web page with a full DOM, Angular makes perfect sense since I'm already comfortable using it.

Angular App to AppGyver- Port to Mobile Solution

I'm beginner to appgyver steroids.
I have angular project. Now I need to make iOS application using AppGyver.
Instead of modify root view and point it to my angular app url (http://www.yourapp.com) can I add my angular app source / angular project build to AppGyver project make it iOS application.
Appreciate your comments
Gayan
You can run steroids create yourApp. This will walk you through the generation of a multi page or single page application. You can then move the structure of your angular application into the /app folder. Check out the example that the steroids create method generates and see the structure there.
You may notice some differences at first. It may take some testing to see what is failing if anything once you port things over. If you used $rootScope for anything it is not as reliable in my experience in an iOS or Android application. There are other methods for passing data between views and broadcasting (publish/subscribe) to other controllers.
You will want to use the iOS simulator or http://localhost:4567/app/moduleName/oneOfYourViewsYouAreTesting.html in your favorite browser while steroids connect is running to debug.
The version of Angular that is coming with this now is AngularJS v1.3.15 installed via bower. You may want to verify things are compatible with your current Angular version.
Ionic is used and Supersonic so you may see conflict with existing CSS or even javascript depending on what you've implemented.
There will be some tricks to learn about preloading views in the structure.coffee file and load times / rootView / initialView. There is lots of support if you come across any issues.
This forum has been really helpful in figuring out any issues I've come across. The Appgyver team is usually pretty responsive to questions directly as well.
They are updating the platform in a few days, and they say big changes are coming. They are hiring a lot of developers right now to take care of GitHub issues as well as build out the rest of their incomplete components.

Is server required to run some CLIENT side DART apps using Polyemer.dart and/or Angular.Dart?

Not sure how to tell my point where, hopei make it as clear as possible.
I tried running some apps that are using Polymer and/or AngularDart, including:
https://www.dartlang.org/docs/tutorials/forms/#about-the-slambook-example
http://bwu-dart.github.io/users
the apps works very fine, one I run them using, "Pub serve" (Aka Ctrl+R from Dart editor), but once I run from the Dartium using the file "URL" things are not working well!!
I got an answer in Dartisans' google+ community the web server is a mus (https://plus.google.com/u/0/110229866977286723923/posts/UAH8ez51S53), is this means neither Polymer nor AngularDarrt are pure client side! by pure client side I mean can run from the file URL, without a web server.
I was thinking to make small app, for learning and testing, and packing it into 2 forms:
1. as Android APK using Android web view, but as server is required
2. as Chrome app
but having both need a web server, and the JavaScript conversion (build) is not acting similar to the output using the file URL, i.e. not completely as required, I got stuck!
Note: I'm using Windows 7, 64x, latest edition of Dart (Dev. 1.6.0), and latest edition of both AngularDart and PolymerDart.
any thought or idea pls
You need a server to serve static content because there are a lot of features with those libraries that are pulling your resources in dynamically. This isn't a Dart or Polymer issue, this is a browser security feature. By default, you can't make AJAX calls to your local machine. Pub serve is handling this for you, but you can chose any server you want to serve your local assets.
Contrary to some of what the other answers are saying, you don't need to build your Dart code when you're in Dartium. Dartium has the Dart VM built in for that very reason.
AFAIK you only need a server, but you need to generate some code, your development code can't directly go to your server, you need to do something like pub build, to make the code ready to be served directly.
You don't need a server, but you do need to build your code. pub serve does this automatically (and keeps on doing it as you change your code, so it's perfect for development), but to be able to use a file:// url, you need to run pub build first, and use the files generated in the build directory.
This is the same issue as discussed here https://stackoverflow.com/a/25248166/217408
and here I tried to reproduce and wasn't able.
After running pub build you can open the build output using a file URL just fine.
Polymer and Angular are definitely pure client side (if you want to use them this way).
That you can't run the Dart code without running pub build first is a bug in DI (used by Angular.dart and bwu_polymer_routing. DI currently requires some code generation that is done only when pub build or pub serve is run.
See also
- https://github.com/angular/angular.dart/issues/1344
- https://github.com/angular/angular.dart/issues/1276
You can try to use the workaround mentioned in issue 1276
Module.DEFAULT_REFLECTOR = new DynamicTypeFactories();

Reusing backbone views/routes on the server when using Backbone.js pushstate for seo/bookmarking

I'm doing some due diligence on backbone for a single page app and wonder if it is possible to re-use the same views/routes from the client on the server side, so that when google visits a pushstate URL, or it is accessed directly, the server can generate the exact same HTML that would be generated by backbone in the client.
It would be a pain to have to maintain two separate sets of views/routes, one on the client and one on the server. I have seen the backnode project on github however this seems to miss the point a bit and you end up having to write the same backbone router twice.
Just wondering how people are generally handling the case when using pushstate urls in backbone and needing to serve the same view from the server? Are people duplicating code or is there a better way?
I haven't tried this yet but these ideas using node.js and backbone might help:
http://andyet.net/blog/2011/feb/15/re-using-backbonejs-models-on-the-server-with-node/
http://bennolan.com/2010/08/13/pushstate-and-nodejs.html
Basically the only way to make it so your not writing the same thing twice is to have both your node.js server and frontend client share the same routing/model code. If you are using something else on the server side (like Ruby) you would have to place node.js in front of your app server. Then make node.js proxy for new clients (push state and client js) and do actually rendering work for old/bot clients.
The other option is doing what jQuery Mobile does which is the Hijax method. The idea to make tons of HTML5 pages (you'll have to look at its routing to see).
And for completeness you should be aware of how google crawls AJAX: http://code.google.com/web/ajaxcrawling/docs/getting-started.html
This project does exactly what you are trying to do. It might interest you to check it out.
https://github.com/developmentseed/bones

Resources