How to truncate text in Angular2?
Is there a way that I could limit the length of the string to a number characters? for e.g: I have to limit a title length to 20 {{ data.title }}. Is there any pipe or filter to limit the length? 11 Answers 11
Is there a way that I could limit the length of the string to a number characters? for e.g: I have to limit a title length to 20 {{ data.title }}. Is there any pipe or filter to limit the length? 11 Answers 11
I came across a strange assignment syntax inside an Angular 2 template. <template let-col let-car=”rowData” pTemplate=”body”> <span [style.color]=”car[col.field]”>{{car[col.field]}}</span> </template> It appears that let-col and let-car=”rowData” create two new variables col and car that can then be bound to inside the template. Source: https://www.primefaces.org/primeng/#/datatable/templating What is this magical let-* syntax called? How does it work? What … Read more
I’m using Angular2 2.1.0. When I want to display a list of companies, I got this error. in file.component.ts : public companies: any[] = [ { “id”: 0, “name”: “Available” }, { “id”: 1, “name”: “Ready” }, { “id”: 2, “name”: “Started” } ]; In file.component.html : <tbody> <tr *ngFor=”let item of companies; let i … Read more
I dont’t know how to add to my component <component></component> a dynamic class attribute but inside the template html (component.html). The only solution I found is to modify the item via “ElementRef” native element. That solution seems a little complicated to do something that should be very simple. Another problem is that CSS has to … Read more
I feel like I am missing something. When I try to use a data attribute in my template, like this: <ol class=”viewer-nav”> <li *ngFor=”#section of sections” data-sectionvalue=”{{ section.value }}”> {{ section.text }} </li> </ol> Angular 2 crashes with: EXCEPTION: Template parse errors: Can’t bind to ‘sectionvalue’ since it isn’t a known native property (“ ]data-sectionvalue=”{{ … Read more
I’m trying to show a checkmark if an answer is the accepted answer: template: `<div ngIf=”answer.accepted”>✔</div>` But I get this error: EXCEPTION: No provider for TemplateRef! (NgIf ->TemplateRef) What am I doing wrong? 2 Answers 2
In my Angular 2 app when I scroll down a page and click the link at the bottom of the page, it does change the route and takes me to the next page but it doesn’t scroll to the top of the page. As a result, if the first page is lengthy and 2nd page … Read more
I am writing an Angular application and I have an HTML response I want to display. How do I do that? If I simply use the binding syntax {{myVal}} it encodes all HTML characters (of course). I need somehow to bind the innerHTML of a div to the variable value. 24 s 24 The correct … Read more