diff --git a/src/rz/angular/add-property-to-html-tag/add-property-to-html-tag.spec.ts b/src/rz/angular/add-property-to-html-tag/add-property-to-html-tag.spec.ts
index 1161c3a..0d60ec9 100644
--- a/src/rz/angular/add-property-to-html-tag/add-property-to-html-tag.spec.ts
+++ b/src/rz/angular/add-property-to-html-tag/add-property-to-html-tag.spec.ts
@@ -6,9 +6,7 @@ describe('addPropertyToHtmlTag', () => {
const fileToBeAddedTo = `
`;
- const codeBlock = {
- '(sideNavToggle)': 'sideNavToggle()'
- };
+ const codeBlock = '{"(sideNavToggle)": "sideNavToggle()"}';
const insertIntoHtmlTag: EditHtmlFile = {
nodeType: 'addPropertyToHtmlTag',
diff --git a/src/rz/angular/add-property-to-html-tag/add-property-to-html-tag.ts b/src/rz/angular/add-property-to-html-tag/add-property-to-html-tag.ts
index 793bafe..417cb47 100644
--- a/src/rz/angular/add-property-to-html-tag/add-property-to-html-tag.ts
+++ b/src/rz/angular/add-property-to-html-tag/add-property-to-html-tag.ts
@@ -5,12 +5,13 @@ import { EditHtmlFile } from '../interfaces/edit-html.interface';
// will insert code into an html block
export function addPropertyToHtmlTag(editFile: EditHtmlFile, fileToBeModified: any): any {
+ const codeBlock = typeof editFile.codeBlock === 'string' ? JSON.parse(editFile.codeBlock) : editFile.codeBlock;
visit(fileToBeModified, { type: 'element', tagName: editFile.tagNameToInsertInto }, (node: any, index) => {
// Check if the tag is the one you want to modify
if (node.tagName === editFile.tagNameToInsertInto) {
node.properties = {
...(node.properties || {}),
- ...editFile.codeBlock
+ ...codeBlock
};
}
});