أيقونات Material Icons

 زر الأيقونات:

<mat-form-field class="w-100">
                        <mat-label>{{'LABELS.ICON' | translate}}</mat-label>
                        <input #icon matInput formControlName="icon" maxlength="50" [(ngModel)]="privilege.icon"
                            [placeholder]="'PLACEHOLDERS.ICON' | translate" [matAutocomplete]="autoGroup" required
                            [type]="'text'">
                        <mat-error *ngIf="form.controls.icon.errors?.required">{{'ERRORS.REQUIRED' |
                            translate}}</mat-error>
                        <mat-icon matSuffix>{{privilege.icon}}</mat-icon>
                        <mat-hint>
                            <a href="https://fonts.google.com/icons" target="_blank">{{'LINKS.BROWSE_ICONS' |
                                translate}}</a>
                        </mat-hint>
                        <mat-hint align="end">{{icon.value.length}} / 50</mat-hint>
                        <mat-autocomplete #autoGroup="matAutocomplete">
                            <mat-optgroup *ngFor="let group of icons"
                                [label]="'ICONS_CATEGORIES.' + group.name | translate">
                                <mat-option *ngFor="let item of group.icons" [value]="item.ligature">
                                    <mat-icon class="icon-edit">{{ item.ligature }}</mat-icon>{{ item.name
                                    }}</mat-option>
                            </mat-optgroup>
                        </mat-autocomplete>
                    </mat-form-field>


طريقة الاستدعاء في ملف الـ TS:

  icons: any[] = [];
  ngOnInit() {
    this.materialIconsService.getItems().subscribe(res => {
      this.icons = res;
    });
    this.lang = this.localStorageService.getLanguageCode();
    if (this.privilege) {
      this.form.setValue(this.privilege);
    }
    else {
      this.privilege = new Privilege();
    }


ملف الخدمة:

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class _MaterialIconsService {
  public url = '/assets/data/';
  constructor(public http: HttpClient) { }
  public getItems(): Observable<any> {
    return this.http.get<any>(this.url + 'material-icons.json');
  }
}


ملف محتوى الأبقونات (material-icons.json):

https://gist.github.com/AmirOfir/daee915574b1ba0d877da90777dc2181


متغيرات الفئة للأيقونات:

    "ICONS_CATEGORIES": {
        "ACTION": "Action",
        "ALERT": "alert",
        "AV": "Audio & video",
        "COMMUNICATION": "Communication",
        "CONTENT": "Content",
        "DEVICE": "Device",
        "EDITOR": "Editor",
        "FILE": "File",
        "HARDWARE": "Hardware",
        "IMAGE": "Image",
        "MAPS": "Maps",
        "NAVIGATION": "Navigation",
        "NOTIFICATION": "Notification",
        "PLACES": "Places",
        "SOCIAL": "Social",
        "TOGGLE": "Toggle"
    },


    "ICONS_CATEGORIES": {
        "ACTION": "حركة",
        "ALERT":"تنبيه",
        "AV":"الصوت والفيديو",
        "COMMUNICATION":"التواصل",
        "CONTENT":"المحتوى",
        "DEVICE":"الأجهزة",
        "EDITOR":"محرر النصوص",
        "FILE":"الملفات",
        "HARDWARE":"المعدات",
        "IMAGE":"الصور",
        "MAPS":"الخرائط",
        "NAVIGATION":"الملاحة",
        "NOTIFICATION":"الإشعارات",
        "PLACES":"الأماكن",
        "SOCIAL":"المجتمع",
        "TOGGLE":"التبديل"
    },











تعليقات

المشاركات الشائعة من هذه المدونة

ngx-extended-pdf-viewer

how to getting access token for https://fcm.googleapis.com/v1/projects/al-ayahya-co/messages:send for angular and backend nestjs

طريقة تفعيل زر Inline Keyboard في Telegram Bot