You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The mock for bidirectional binding to a signal model is missing the model output event emitter.
The ngMocks.output function cannot access the model's output using the model name with the 'Change' suffix.
An example of the bug
TypeError: ng_mocks_1.ngMocks.output(...).emit is not a function
Important: The issue only appears if change detection occurs after the component is created. Otherwise, the bug does not manifest.
It seems that in the case of two-way binding to signal model, Angular adds an output to the component metadata, where the output name matches the model property, and its alias is the model property name with a 'Change' suffix.
I can fix this issue as follows:
diff --git a/libs/ng-mocks/src/lib/common/func.directive-io-parse.ts b/libs/ng-mocks/src/lib/common/func.directive-io-parse.ts
index d818160139..e2a8c59c61 100644
--- a/libs/ng-mocks/src/lib/common/func.directive-io-parse.ts+++ b/libs/ng-mocks/src/lib/common/func.directive-io-parse.ts@@ -8,6 +8,10 @@ export default function (param: DirectiveIo): DirectiveIoParsed {
return { name };
}
+ if (name + 'Change' === alias) {+ return { name: alias }; // model output+ }+
return { name, alias };
}
Description of the bug
The mock for bidirectional binding to a signal model is missing the model output event emitter.
The ngMocks.output function cannot access the model's output using the model name with the 'Change' suffix.
An example of the bug
Important: The issue only appears if change detection occurs after the component is created. Otherwise, the bug does not manifest.
Expected vs actual behavior
The text was updated successfully, but these errors were encountered: