In the tutorial here:
https://angulardart.dev/guide/user-input#put-it-all-together
The sample code (excerpt) below is obsolete:
<input #newHero
(blur)="addHero(newHero.value); newHero.value='' ">
The code will cause this error:
"Event bindings no longer support multiple statements"
The workaround I found is to rewrite the function addHero() to take an InputElement like this:
void addHero(InputElement target) {
// add hero blah blah
target.value = '';
}
However, the whole section in that tutorial is teaching us not to pass in any DOM Element.
Is there any better solution?
$event
(blur)="addHero($event)"
void addHero(Event event) {
// add hero blah blah
event.target.value = '';
}
you can bind a variable to the input using ngModel
@Component(
...
directives: [formDirectives, ...],
...
)
class MyComponent {
...
String myHeroName;
void addHero() {
// add hero here using bound variable "myHeroName"
// done, reset the hero name
myHeroName = '';
}
...
}
<input [(ngModel)]="myHeroName" (blur)="addHero()" />
@worookie
Is anyone able to get pageloader to work nowadays?
I am learning Page Loader from the official tour guide and got stuck at:
https://angulardart.dev/guide/testing/component/page-objects#pubspec-configuration
There is always some kind of version conflict when trying to add the "pageloader" dependency to the pubspec.yaml file.
I know the angulardart site is historical, but would like to know if anyone is still able to use "pageloader".
My original questions can be simplified to:
What version of pageloader do you use?
Oh my God. I do not believe that! I chose Aqueduct and the angular dart for an important project. Both were orphaned.
I quoted a comment up there for you. To be cleared it's not abandoned, there are updates occasionally. However, users are not active. They put most effort for Flutter.
Hello
I am getting experimental related error once I try to pub get
or pub serve
, I am not sure how this happened, after it was working fine
environment:
sdk: '>=1.24.0 <2.0.0'
dependencies:
angular: ^4.0.0
angular_router: ^1.0.2
angular_forms: ^1.0.0
..
...
dev_dependencies:
browser: ^0.10.0+2
dart_to_js_script_rewriter: ^1.0.3
dart_style: any
transformers:
- angular:
entry_points:
- web/main/main.dart
- dart_to_js_script_rewriter
- $dart2js:
commandLineOptions: [--show-package-warnings]
I am getting something like
xxxxxxxxxx$ pub get
Resolving dependencies...
Got dependencies!
Precompiling dependencies...
Loading source assets...
Loading angular transformers...
[BuilderTransformer: Instance of 'LibraryBuilder' on angular|primary]:
Error running TemplateGenerator for angular|lib/experimental.dart.
Error: Bad state: Could not resolve @get experimental → _Experimental. An import or dependency may be missing or invalid.
Stack Trace:
#0 TypeChecker._computeConstantValue (package:source_gen/src/type_checker.dart:99)
#1 TypeChecker.annotationsOfExact.<anonymous closure> (package:source_gen/src/type_checker.dart:122)
#2 MappedListIterable.elementAt (dart:_internal/iterable.dart:413)
#3 ListIterator.moveNext (dart:_internal/iterable.dart:342)
#4 WhereIterator.moveNext (dart:_internal/iterable.dart:437)
#5 Iterable.isEmpty (dart:core/iterable.dart:383)
#6 TypeChecker.firstAnnotationOfExact (package:source_gen/src/type_checker.dart:84)
#7 ReflectableReader.resolve.<anonymous closure> (package:angular_compiler/src/analyzer/reflector.dart:121)
#8 WhereIterator.moveNext (dart:_internal/iterable.dart:438)
#9 MappedIterator.moveNext (dart:_internal/iterable.dart:390)
#10 List.addAll (dart:core-patch/growable_array.dart:197)
#11 ReflectableReader.resolve (package:angular_compiler/src/analyzer/reflector.dart:120)
<asynchronous suspension>
#12 processTemplates (package:angular/src/source_gen/template_compiler/template_processor.dart:46)
<asynchronous suspension>
#13 TemplateGenerator.generate.<anonymous closure> (package:angular/src/source_gen/template_compiler/generator.dart:29)
<asynchronous suspension>
#14 _rootRun (dart:async/zone.dart:1120)
#15 _CustomZone.run (dart:async/zone.dart:1001)