Skip to content

Commit

Permalink
fix(astro-angular): check the component inputs before setting (#81)
Browse files Browse the repository at this point in the history
Related to #79
  • Loading branch information
simitch1 authored Sep 7, 2022
1 parent 78feab2 commit c440629
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/astro-angular/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import 'zone.js/dist/zone.js';
import type { ɵComponentType as ComponentType } from '@angular/core';
import {
reflectComponentType,
ɵComponentType as ComponentType,
} from '@angular/core';
import { ApplicationRef, NgZone, createComponent } from '@angular/core';
import { createApplication } from '@angular/platform-browser';

Expand All @@ -17,9 +20,17 @@ export default (element: HTMLElement) => {
hostElement: element,
});

if (props) {
const mirror = reflectComponentType(Component);
if (props && mirror) {
for (const [key, value] of Object.entries(props)) {
componentRef.setInput(key, value);
if (
mirror.inputs.some(
({ templateName, propName }) =>
templateName === key || propName === key
)
) {
componentRef.setInput(key, value);
}
}
}

Expand Down

0 comments on commit c440629

Please sign in to comment.