SPA Angular [Title] component mapping | Community
Skip to main content
Level 3
May 7, 2020
Question

SPA Angular [Title] component mapping

  • May 7, 2020
  • 0 replies
  • 877 views

I am attempted to map the Title component in an SPA, but was curious how others were able to map the "type" property to the title.component.html file.

 

title.component.ts

import { Component, Input, OnInit } from '@angular/core'; import {MapTo} from '@adobe/cq-angular-editable-components'; @Component({ selector: 'app-title', templateUrl: './title.component.html', styleUrls: ['./title.component.css'] }) export class TitleComponent implements OnInit { @2705597() type: string; @2705597() text: string; constructor() { } get hasTitle() { return this.text && this.text.trim().length > 0; } ngOnInit() { } } const TitleEditConfig = { emptyLabel: 'Title', isEmpty: function(componentData) { return !componentData || !componentData.text || componentData.text.trim().length < 1; } }; MapTo('angularapp/components/title')(TitleComponent, TitleEditConfig);

title.component.html

<ng-container *ngIf="hasTitle"> <{{type value}}> {{text value}} </{{type value}}> </ng-container>

Has anyone achieved this?

 

Thanks!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.