简体   繁体   中英

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:

  1. https://www.dartlang.org/docs/tutorials/forms/#about-the-slambook-example
  2. 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, ie 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您只需要一个服务器,但是您需要生成一些代码,您的开发代码不能直接进入您的服务器,您需要执行诸如pub build之类的事情,以使这些代码可以直接提供。

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM