Coder Social home page Coder Social logo

Comments (6)

fknop avatar fknop commented on May 13, 2024

Could you give me the code that produces this error ? Typescript and HTML.

from angular-pipes.

Faey2222 avatar Faey2222 commented on May 13, 2024

HTML:

<nav ngIf="metaCategories">
  <ul class="nav nav-tabs">
    <li ngFor="let category of metaCategories | objToArr | orderBy: 'position'" class="nav-item">
      <a href="#" class="nav-link">
        <i class="fa {{category.icon}}" title="{{category.name}}"></i>
      </a>
    </li>
  </ul>
</nav>

TypeScript:

import {Component, OnInit} from '@angular/core';
import * as globals from '../../shared/globals';
import {ShareService} from "../../shared/share-service";

@Component({
  selector: '[syLiveEditMetabar]',
  inputs: ['syLiveEditMetabar'],
  templateUrl: 'metabar.component.html',
  styles: []
})
export class MetabarComponent implements OnInit {
  private syLiveEditMetabar;
  private metaCategories = [];
  private metaConfiguration;

  constructor(private shareService: ShareService) { }

  ngOnInit() {
    this.shareService.getPageData()
      .subscribe(
        result => {
          if(result.metaConfiguration && !this.metaConfiguration) {
            this.metaConfiguration = result.metaConfiguration;

            /**
             * Define used metaCategories
             */
            for(var x = 0; this.metaConfiguration.groups.length != x; x++) {
              if(globals.MetaCategories) {
                for(var category in globals.MetaCategories) {
                  if(globals.MetaCategories[category].alias == this.metaConfiguration.groups[x].category) {
                    this.metaCategories[category] = globals.MetaCategories[category];
                  }
                }
                //this.metaConfiguration.groups[x]
              }
            }
            console.log(this.metaCategories);
          }
        }
      )
  }

}

Result of the subscription (result.metaConfiguration) is:
{ groups: [ { name: "Seiten-Informationen", alias: "seiteninformationen", visible: false, position: "1", category: "Basicdata" }, { name: "Veröffentlichung", visible: false, position: "2", category: "Basicdata" }, { name: "Sicherheit", visible: true, position: "1", category: "Security" } ] , elements: [ { label: "Seiten-Titel", alias: "Titel", type: "text", group: "seiteninformationen", mandatory: true, validations: [ "min:3" ] }, { label: "Seiten-Alias", alias: "Alias", type: "text", group: "seiteninformationen", mandatory: false, validations: [] } ] };

Result of globals.MetaCategories is:
{ Basisdaten: { name: 'Basisdaten', alias: 'Basicdata', icon: 'fa-info', position: 4 }, Security: { name: 'Sicherheit', alias: 'Security', icon: 'fa-users', posiiton: 2, }, Settings: { name: 'Einstellungen', alias: 'Settings', icon: 'fa-wrench', position: 3 } };

from angular-pipes.

fknop avatar fknop commented on May 13, 2024

objToArr is one of your own pipe ?

from angular-pipes.

Faey2222 avatar Faey2222 commented on May 13, 2024

Yes.

import {Pipe, PipeTransform} from '@angular/core';

@Pipe({
  name: 'objToArr',
  pure: false
})

export class ObjToArr implements PipeTransform {
  /**
   * Pipe (filter) to transform an object to an array
   * @param object
   * @returns {Array}
   */
  transform(object: any) {
    var newArray = []
    for (var key in object) {
      newArray.push(object[key]);
    }
    return newArray;
  }
}

from angular-pipes.

fknop avatar fknop commented on May 13, 2024

Could you maybe print what comes out of objToArr ? To check if it's really an array of numbers only.

from angular-pipes.

Faey2222 avatar Faey2222 commented on May 13, 2024

Unfortunately the result of objToArr results in something else than expected. Guess you can close this issue :) Thanks.

from angular-pipes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.