angular-dart

Angular Dart passing data from route service into a controller

牧云@^-^@ 提交于 2019-12-06 12:19:16
问题 I'm struggling to find a way to get data from my router into my controller. The enter method on the route is correctly grabbing the data from the service, as the print method shows the JSON response in the console. My Module looks like this: class MyAppModule extends Module { MyAppModule () { type(UsersService); type(UsersController); type(RouteInitializerFn, implementedBy: MyAppRouteInitializer); factory(NgRoutingUsePushState, (_) => new NgRoutingUsePushState.value(false)); } } and a

Setup global Http request Headers on angular dart

喜夏-厌秋 提交于 2019-12-06 08:09:00
问题 How can I configure the Http service adding headers to the call. I try the following class GlobalHttpHeaders { static setup(Injector inj){ HttpDefaultHeaders http = inj.get(HttpDefaultHeaders); http.setHeaders([{"X-Requested-With":"XMLHttpRequest"}], "COMMON"); } } And in the app the last line is: Injector inj = ngBootstrap(module: new SiteIceiModule()); GlobalHttpHeaders.setup(inj); But that don't work. 回答1: (I think) I got it working with: @Injectable() class MyDefaultHeaders extends

How does AngularDart dependency injection work?

旧巷老猫 提交于 2019-12-05 20:59:09
I have an component that needs to access its root element from the Dart code. By reading Differences between Angular.js and Angular.dart? here on SO and grepping around in the AngularDart source code I figured out that what I need is to provide a constructor with explicitly typed arguments. If one of the arguments has type dom.Element , it will be given the reference to my components root by the Angular injector. (Failing to have types on the constructor arguments results in an exception NoSuchMethodError : method not found: 'simpleName' being thrown from deep down in Angular internals.) My

How do I use AngularDart when my static files are on a CDN with a varying URL?

孤街浪徒 提交于 2019-12-05 14:25:18
I'm using AngularDart for a new application of mine. I have a component set up like so: @NgComponent( selector: 'game-timeline', templateUrl: '/static/dart/game/web/views/timelineview.html', cssUrl: '/static/dart/game/web/views/timelineview.css', publishAs: 'ctrl' ) But my problem is, the template and css locations aren't necessarily known at build-time. They'll be on a CDN with a unique deploy-identifier on them. Something like... http://cdn.domain.com/static/30294832098/dart/game/web/views/timelineview.html And that number varies every deploy. The path seems to be relative to the html page

I have an AngularDart component, how to get the text input field to auto-focus every time the component shows?

谁都会走 提交于 2019-12-05 08:23:09
I have a text input in a AngularDart component like the following: <input type="email" id="inputFirstName" ng-model="cmp.inputFirstName"> How can I make the text input auto-focus every time the component shows? I tried setting the html5 attribute autofocus, but that only works on the first time the component is displayed. Günter Zöchbauer You could try to use a custom Directive (new Decorator) for this: import 'package:angular/angular.dart' as ng; import 'dart:html'; @ng.Decorator(selector: '[autofocus]') class AutoFocusDecorator implements ng.AttachAware{ InputElement inputElement;

Other way that type() in angular dart

喜夏-厌秋 提交于 2019-12-05 07:17:46
I did the angular dart tutorial and I have a question about it. To declare a type available for dependecy injection, I have to do this: class MyAppModule extends Module { MyAppModule() { type(RecipeBookController); } } And so on for all types. In a big app, you can have hundreds type, so it's a weird way to declare all types. Is there any other way to do this? Thanks. Günter Zöchbauer You can use reflection to collect the types. Please add a comment if you need more information about this approach (I try to avoid reflection in web apps). EDIT Reflection may work, but when you start using

In Dart Angular, how to pass functions to component

无人久伴 提交于 2019-12-05 06:42:28
I have a component MyComp and I would like to pass a function to it as parameter. More precisely I would like to do something like that: dart component file: @NgComponent( selector: 'mycomp', publishAs: 'ctrl', map: const { 'myfunc' :'=> myfunc' } ) class MyComponent { Function myfunc; .... myfunc(); } html: <mycomp myfunc="ctrl.myfunc"></button-list> The problem is that myfunc is null in the component. Do I miss something? How can I do that? Ozan Use '&' to bind a function to a field: @NgComponent( selector: 'mycomp', publishAs: 'ctrl', map: const { 'myfunc' :'&myfunc' } ) class MyComponent {

Angular Dart passing data from route service into a controller

二次信任 提交于 2019-12-04 19:55:56
I'm struggling to find a way to get data from my router into my controller. The enter method on the route is correctly grabbing the data from the service, as the print method shows the JSON response in the console. My Module looks like this: class MyAppModule extends Module { MyAppModule () { type(UsersService); type(UsersController); type(RouteInitializerFn, implementedBy: MyAppRouteInitializer); factory(NgRoutingUsePushState, (_) => new NgRoutingUsePushState.value(false)); } } and a simplified version of my router class MyAppRouteInitializer { final UsersService _userService;

Progressive web app and AngularDart

亡梦爱人 提交于 2019-12-04 10:45:27
I am currently looking for a web framework for my next project and for some reasons I'm interested in angular dart . But at the same time I want my webapp to follow PWA guidelines. I searched quite a lot, but I haven't found an example of PWA in angulardart. I saw some examples for the JS counterpart or found pwa dart package, but I lack the knowledge of angulardart framework to know if it's possible in dart. So, is it possible to make a PWA in angulardart ? Deferred loading in plain Dart https://news.dartlang.org/2014/08/dart-16-adds-support-for-deferred.html Angular supports deferred loading

Verifying route preconditions prior to loading controller

自作多情 提交于 2019-12-03 12:44:30
I'm writing a single page application in Angular, specifically angular.dart , but I'm assuming this question still applies to AngularJS. Take for example the following routes: /login - Expects nobody to be logged in. If someone is authenticated but not registered, redirect to "register" route, if they are registered, redirect to the "home" route. /register - Expects an authenticated user who hasn't finished the registration process. If not authenticated, redirect to login. If is authenticated, redirect to home. /home - Expects an authenticated and registered user. If not authenticated,