Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipe with several params can't be applied within function call #1669

Closed
yury-yufimov opened this issue Nov 24, 2018 · 1 comment

Comments

Projects
None yet
3 participants
@yury-yufimov
Copy link

commented Nov 24, 2018

Dart SDK: Dart VM version: 2.1.0 (Tue Nov 13 18:22:02 2018 +0100) on "macos_x64"
AngularDart: 5.1.0
macOS
Chrome

It seems, that angular templates compiler couldn't handle such rare case:
"pipe with multiple parameters, applied to argument of function, called within template"

Here's an example:

app_component.html

<h1>My First AngularDart App</h1>

<h3>Working Example 1 - pipe with several params</h3>
{{testVal | myPipe2:param1:param2 }}

<h3>Working Example 2 - function call</h3>
{{formatValue(testVal)}}

<h3>Working Example 3 - function call with pipe1 on param</h3>
{{formatValue(testVal | myPipe1:param1 )}}

<h3>Broken Example 4 - function call with pipe2 on param</h3>
{{formatValue(testVal | myPipe2:param1:param2  )}}

app_component.dart

import 'package:angular/angular.dart';

@Component(
  selector: 'my-app',
  templateUrl: 'app_component.html',
  pipes: [MyPipe1, MyPipe2]
)
class AppComponent {
  String get testVal => 'APP';
  String get param1 => 'FIRST';
  String get param2 => 'SECOND';

  String formatValue(String value) {
    return 'Formatted: $value';
  }
}

@Pipe('myPipe1')
class MyPipe1 implements PipeTransform {
  String transform(dynamic value, String param) {
    return '$value, p1:$param';
  }
}
@Pipe('myPipe2')
class MyPipe2 implements PipeTransform {
  String transform(dynamic value, String param1, String param2) {
    return '$value, p1:$param1, p2:$param2';
  }
}

project compilation will result in such error:

[SEVERE] build_web_compilers|ddc on lib/app_component.template.dartdevc.module (cached):
Error compiling dartdevc module:ng_test|lib/app_component.template.ddc.js

[error] The argument type '(dynamic, String, String) → String' can't be assigned to the parameter type '(dynamic, String) → String'. (package:ng_test/app_component.template.dart, line 74, col 44)
[error] 2 required argument(s) expected, but 1 found. (package:ng_test/app_component.template.dart, line 98, col 78)
[error] The named parameter 'param1' isn't defined. (package:ng_test/app_component.template.dart, line 98, col 93)

Please fix all errors before compiling (warnings are okay).

Here is an example project:
ng_pipe_test.zip

alorenzen added a commit that referenced this issue Jan 17, 2019

matanlurey added a commit that referenced this issue Jan 18, 2019

@matanlurey

This comment has been minimized.

Copy link
Contributor

commented Apr 11, 2019

Fixed by 3b631b2.

@matanlurey matanlurey closed this Apr 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.