angular-dart

How to make two-way data binding between service and controller

戏子无情 提交于 2020-01-06 14:09:55
问题 I have a service and I have been trying to make a two-way binding to one of the service's properties within controller. Below is a code for three different approaches. The first uses $watch() , the second uses getter/setter and the third uses attribute with @NgTwoWay -binding. I think the third one is the cleanest solution, but is it possible to write the code without the wrapper controller (test-ctrl)? Is there a better way to do the binding? ang.dart import 'package:angular/angular.dart';

setInnerHtml doesn't evaluate Mustache

[亡魂溺海] 提交于 2020-01-05 12:15:52
问题 I add some HTML content adding setInnerHtml() inside my NgComponent. Logging shows, that directives are instantiated but {{ctrl.xxx}} expressions are not evaluated. For setting the HTML I use a directive derived form ng-bind-html with a custom NodeValidator and the following value method. set value(value) { _element.setInnerHtml((value == null ? '' : value.toString()), validator: validator); _log.finest(value); if(value != null) { BlockFactory template = _compiler(_element.children,

Input onchange with Angular2

你离开我真会死。 提交于 2020-01-05 06:26:09
问题 I try to detect on change with dart. Example html: <div> <input id="photoUpload" type="file" name="photo" (onchange)="update()" multiple> </div> Dart: @Component( selector: "photo-upload-dialog", templateUrl: "photo_upload_dialog.html") class PhotoUploadDialog { update() async { print('Changed!'); } } But nothing in a console. 回答1: onChange is the default event handler name, not the event name. Use instead (change)="update()" 来源: https://stackoverflow.com/questions/38291410/input-onchange

Importing SCSS partials in Angular Dart

风格不统一 提交于 2020-01-05 04:21:13
问题 I am building a project with Angular Dart (My first serious one). I am familiar with SCSS and have used it in other 'normal' non-angular non-dart related projects. However, SCSS in AngularDart behaves way differently than I'm used to, and it's leaving me a little confused. The thing I'm struggling with right now is how to import partials. In 'normal' scss I would do something like this to import _mixins.scss : @import 'mixins'; In my angular dart project, I tried doing something similar. The

Angular Dart $scope.$on functionality is not working

那年仲夏 提交于 2020-01-04 02:34:10
问题 I want to call a destroy function when the dart-angular controller are removed. This is the angular.js solution. $scope.$on("$destroy", function() { alert("destroy"); }); My try in Dart class TestController... TestController(Scope $scope){ $scope.$on("$destroy",(){ print("destroy"); }); } and this is the Error Code Error! NoSuchMethodError : method not found: 'destroy' $destroy or destroy literal is not working. Any Idea? 回答1: I think this is a better way class TestConroller implements

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

拥有回忆 提交于 2020-01-02 03:24:07
问题 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. 回答1: 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]'

How to serve several different directories in Angular Dart project?

心已入冬 提交于 2019-12-30 10:52:21
问题 I'm trying to set up several configurations in my Angular Dart project, to make it possible to serve and build different versions of Angular application from several different top level directories (apart from standard web directory) For a demonstration I've created standard Angular Dart application from template ( https://github.com/vadimtsushko/two_configs_test ), and have copied web directory to web2 . I can successfully run application from web directory with pub run build_runner serve

How to inject services into RouteInitializerFn (new routing DSL)

蹲街弑〆低调 提交于 2019-12-30 08:34:40
问题 I'm switching my app over to the new routing DSL. Specifically, I want to do something like this with preEnter : final RouteInitializerFn routes =(Router router, ViewFactory views) { views.configure({ 'chat': ngRoute( path: '/chat', // authService.requireState returns a Future<bool>, and may invoke an HttpRequest preEnter: (RoutePreEnterEvent e) => e.allowEnter(authService.requireState(LOGGED_IN)), view: 'views/chat.html'), 'login': ngRoute( path: '', defaultRoute: true, view: 'views/login

How to inject services into RouteInitializerFn (new routing DSL)

北战南征 提交于 2019-12-30 08:34:08
问题 I'm switching my app over to the new routing DSL. Specifically, I want to do something like this with preEnter : final RouteInitializerFn routes =(Router router, ViewFactory views) { views.configure({ 'chat': ngRoute( path: '/chat', // authService.requireState returns a Future<bool>, and may invoke an HttpRequest preEnter: (RoutePreEnterEvent e) => e.allowEnter(authService.requireState(LOGGED_IN)), view: 'views/chat.html'), 'login': ngRoute( path: '', defaultRoute: true, view: 'views/login

HTML dropdown with ng-options binding does not work with angular-dart

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 13:09:06
问题 Angular-dart ng-options does not seems to be working. <select ng-model="selectedOption" ng-options="s.DisplayText for s in myOptions"> <option value="">Select Option</option> </select> 回答1: <select ng-model="selectedOptionId"> <option value="">Select Option</option> <option ng-repeat="o in myOptions" value="{{o.id}}"> {{o.DisplayText}} </option> </select> Note that selectedOptionId is string, if we use myOption(type with id and DisplayText as properties) as model it will add new option with "