Changing font awesome icons through Angular components - html

I am using font-awesome version 4.7.0 with Angular 5. When I add an icon to a screen the icon immediately changes from tag to and I cannot access its class from an Angular component which is what I want to do.
The resulting behavior is that the first icon defined is shown properly but any subsequent changes I make that should be reflected on the UI with a change of the font awesome icon are not shown at all.
The specific problem is that I wan the icons to change when sorting a table. The initial icon is set up to be fa-sort, and it displays correctly, but when clicking on the table header, the content gets sorted and updated but the icons dont change to fa-sort-up or fa-sort-down. I've tested the logic and it works properly.
The current HTML code which should be performing this action looks like this:
<i [ngClass]="sortBy.key !== 'login' ? 'icon-sort' : sortBy.order === 'desc' ? 'icon-sort-up' : 'icon-sort-down'"></i>

This is because fontawesome replaces your tag with . To change icons use this template (use in class that you need):
<span *ngIf="sortAsc"><i class="icon-sort-up"></i></span>
<span *ngIf="!sortAsc"><i class="icon-sort-down"></i></span>

Try maybe assigning the icon within the component code itself, such as:
in Component
getIcon(){
sortBy.key !== 'login' ? 'icon-sort' : sortBy.order === 'desc' ? 'icon-sort-up' :
'icon-sort-down'
}
I think it has to do with change detection, or you can manually trigger it after you sort, by importing change detection.
ex:
`constructor(cd: ChangeDetectorRef) {}`
and then in your code,
this.cd.detectChanges();

Related

Icons showing as garbage symbols on refresh of page

I am using some custom icons in my application, as show below.
However when I refresh the page, or sometimes on some other action, the icons change to these garbage symbols. This happens randomly. Is there any permanent solution for this?
Here is a bit of the sample code where these icon classes are used. These are custom icons and the icon.css is added to the assets folder.
[ngClass]="{'disable':disableDeleteIcon()}" (click)="deleteContact()"></span>
<span class="icon-edit grid-renderer-edit-icon" title="Edit"
*ngIf="params.colDef.headerName == 'Action' && !params.isDeletedRecords" [ngClass]="{'disable':disableEditIcon()}"
(click)="editContact()"></span>
<span class="icon-refresh grid-renderer-restore-icon" title="Restore"
*ngIf="params.colDef.headerName == 'Action' && params.isDeletedRecords" (click)="restoreContact()"></span>```

angular material progress bar is not getting displayed

I am trying to use progress bar but it's not getting displayed , but when i inspect i see the tags present. Following is what i have done till now. attaching the screenshot for your reference. Also i need details like i am using angular material to render all the components like table , checkbox but it still shows in old style.
my app.component.html :
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
checkbox :

How to prevent default title setting on Vue Component?

I am using Vue Material Design Icons ref, and they automatically have a title attribute set - by default it is a human readable form of the icon's name, e.g. Plus Icon. Because this is being imported directly from the Node Package, I don't want to mess with the components themselves. I also know that I could write some custom JS to fix it, but I don't really want to do that.
Is there a standard way to disable the title attribute during component registration or in some other fashion that doesn't add a performance cost or require any patchwork code?
note: I'm also using Webpack if this can be done that way.
From the link you've provided, that icon component provides a prop where you can set the title to whatever you wish if you don't want to use the default.
Props
title - This changes the hover tooltip as well as the title shown to screen readers. By default, those values are a "human readable"
conversion of the icon names; for example chevron-down-icon becomes
"Chevron down icon".
Example:
<android-icon title="this is an icon!" />

How to change ion-nav-bar background colour dynamically

I am new to ionic app development and basically i have a radio list a user can select options from and for each option i have set up a background colour and what i want it to do is to change the background colour whenever the user selects an option. the problem is that it changes to the initial option but it doesn't change the colour after the initial load although when i inspect the page i can see it has changed the class name.
this is my html
<ion-nav-bar class="bar-{{viewColor}} nav-title-slide-ios7" align-title="center">
<ion-nav-back-button class="button-icon ion-arrow-left-c">
</ion-nav-back-button>
</ion-nav-bar>
and this is how i am assigning the viewColor variable in my js
$scope.viewColor = "positive";
thanks in advance
Try using ionicView.beforeEnter method, set the viewcolor value before the page has finish loaded.
$scope.$on('$ionicView.beforeEnter', function () {
$scope.viewColor = "positive";
});
After playing around with different solutions (which didn't work) I ended up using ion-header-bar instead of ion-nav-bar and it works! The colour changes dynamically with the users selections. The only downside to it is that I have to create a header for each view and handle the application state myself

Prevent icon conflict when using FontAwesome with PrimeFaces

I have a problem with menu icons in PrimeFaces : the UI icon seems to be in conflict with the FontAwesome one.
Here is a screenshot:
When I look in my browser's inspector, I can see that four classes are applied to the div: ui-menuitem-icon, ui-icon, fa and fa-terminal.
Removing one or both of ui-menuitem-icon or ui-icon solves the problem. But, I would like to do it without some ugly script.
Here is how the menubar is displayed (please note that this line is in a layout (as a header)) :
<p:menubar model="#{menuGenerator.menu}" style="margin-bottom: 20px"></p:menubar>
My model is generated with the following method :
public MenuModel getMenu(){
MenuModel result = new DefaultMenuModel();
result.addElement(new DefaultMenuItem("SQL", "fa fa-terminal", "/"));
//...
result.generateUniqueIds();
return result;
}
The parameter primefaces.FONT_AWESOME is set to true.
I'm currently using Primefaces 5.0, and Mojarra 2.2.12.
How do I make the menu appear without the conflict between the UI icon and the FontAwesome one (e.g. with only one of the two classes ui-menuitem-icon, ui-icon applied to the div)?