question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Angular Directives Not Working Under FormattedString Span Tag

See original GitHub issue

For Some reason Angular Ng Directives are not working Following is a code sample:

<Button dock="top" class="btn btn-primary btn-rounded-lg" style="margin: 5;">
    <FormattedString>
        <Span text="Question {{state.questionNumber}}"></Span>
        <Span *ngIf="isPracticeMode()" text=" of {{state.totalQuestions}}">
        </Span>
    </FormattedString>
</Button>

When you toggle between items where isPractiveMode gives you true and false then the Formatted String becomes longer and longer. Please find the image attached.

image

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:5
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
trunkovichcommented, Mar 17, 2018

@rakeshgirase I’d suggest you creating FormattedString in component and bind it to the Label. Example:

  formattedString: FormattedString;

  ngOnChanges(changes): void {
    if (changes && changes.job && changes.job.currentValue) {
      this.formattedString = this.generateValuesFormattedString(changes.job.currentValue);
    }
  }

  generateValuesFormattedString(job: Job): FormattedString {
    const formattedString = new FormattedString();
    _.each(job.values, (value, i) => {
      const titleSpan = new Span();
      const answerSpan = new Span();
      titleSpan.text = `${value.attribute.title}\n`;
      let answer = `${getAnswer(value)}`;
      answer += i < (job.values.length - 1) ? '\n\n' : '';
      answerSpan.text = answer;
      answerSpan.color = new Color('#333333');
      formattedString.spans.push(titleSpan, answerSpan);
    });

    return formattedString;
  }

<Label *ngIf="formattedString" textWrap="true" [formattedText]="formattedString"></Label>

0reactions
Bidou44commented, Oct 10, 2019

@tsonevn This is still not working, should I create a new issue for this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Directives Not Working Under FormattedString Span Tag
For Some reason Angular Ng Directives are not working. Following is a code sample: <Button dock="top" class="btn btn-primary btn-rounded-lg" style="margin: ...
Read more >
angular4 directive not working inside HTML SPAN tag
I have written a directive in angular4, which works on input fields. When I apply that on SPAN tag, it is not working....
Read more >
FormattedString - NativeScript Docs
FormattedString is a special class, which provides a support various text transformations and decorations. This class can be used in all text-related ...
Read more >
date - AngularJS: API
Formatted string or the input if input is not recognized as date/millis. Example. Edit in Plunker. index.html protractor.js. <span ...
Read more >
Style for Label.FormattedString.Span broke...
I could not select a Span in the TargetType so I had to select Label. The problem showed itself by not opening the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found