¿Como colorear lineas según un dato en un listado en Angular 7?

Pues he buscado pero no me queda nada claro. esto es tal como lo tengo para ilustraros del problema

<ng-container *ngFor="let dato of datos; let i = index" [ngStyle]="{'background-color': dato.versionapi = Inaccesible : 'red'}">     <div class="row justify-content-md-center" style="padding-bottom: 5%; border: 100px; background-color:#243a51; color:#ffffff">         <div class="col col col-lg-3">             {{ dato.nombre }}         </div>         <div class="col col col-lg-3">             {{ dato.ws }}         </div>         <div class="col col col-lg-3  row justify-content-center">             {{ dato.versionapi }}         </div>         <div class="col col col-lg-3  row justify-content-center">             {{ dato.ws_provider }}         </div>     </div>     <hr style="color: #000000;" /> </ng-container> 

La idea es que la fila en la que el dato.versionapi sea igual a Inaccesible toda la fila se ponga en rojo.

How to prevent angular 2 client from accessing privileged fields

I’m learning angular and have been reading about various backend solutions like direct db access, REST, and graphql. One thing I haven’t seen addressed anywhere yet is how do you protect privileged information from being leaked to an unprivileged user.

Say I have a list of users with the properties id, displayname, loginname and passwordhash. And say my app shows a list of all users. How do I prevent the password hashes from being sent to every client requesting this view?

How to find the Eulerian circuit with the minimum accumulative angular distance within a Eulerian graph?


Context

For context, this problem is part of my attempt to determine the path of least inertia for a free and open-source laser scanner DAC API I am developing. The following problem arises during the vector image optimisation pass. I convert the 2D vector image into a graph of 2D positions and add blank edges (i.e. transparent lines) to represent the image as a strongly connected, undirected Eulerian graph from which I should be able to determine the optimal Eulerian circuit.

Problem

Given a strongly connected, undirected Eulerian graph (i.e. each vertex has an even degree), I’m trying to determine the Eulerian circuit that results in the minimum possible accumulative angle, where each vertex is a position in 2D space and each edge describes a straight line between the vertices.

My Solution Attempt

My attempt at solving this was to first simplify the problem by looking at each vertex individually. We know that each vertex must have an even degree, and thus for each vertex there must be an optimal set of incoming/outgoing edge pairs (where each edge is used once) that results in a minimum accumulative angular distance. By minimum accumulative angular distance, I’m referring to the sum of the difference between the result of the difference between the angle of each incoming/outgoing edge pair and a straight line. For example, given the following vertex A and its neighbours B, C, D and E:

enter image description here

an example of optimal pairs would be (DA, AB) and (EA, AC) as they are cumulatively the least sharp angles through which A may be traversed (and in turn would induce the least inertia), whereas the pairs (EA, AD) and (BA, AC) would be the least optimal as cumulatively they contain the sharpest angles to be traversed (resulting in the highest inertia).

Once the set of optimal pairs is determined for each vertex, I suspect the Eulerian Circuit can be created by starting at one of the vertices, picking a direction to begin and following the optimal pairs until the beginning is reached again.

My Solution Attempt Issues

Currently however I’m running into two issues.

  1. I don’t know for sure whether or not my assumption holds true for all Euler graphs (where all nodes have an even degree).
  2. I’m unsure of the best approach for determining the set of optimal edge pairs for each vertex. I suspect it may be possible to represent each vertex and its edges as a sub-graph and treat the problem as finding the shortest path (where the “shorter” distances are the paths through the vertex that result in the straightest angles), but I’m struggling to come up with a sub-graph representation that would allow me to do this.

Related Research

In section 3.4 of Accurate and Efficient Drawing Method for Laser Projection the paper describes using Hierholzer’s algorithm for finding an optimal Eulerian circuit with the amendment that during traversal of each vertex you select the unvisited edge along the angle closest to a straight line. One issue that occurs to me with this approach is that it is not clear to me that this always results in the absolute optimal circuit, only one that is probably more optimal than a naive construction without this added amendment.

Questions

  1. Is there an existing solution to the original Problem stated above? If so, is there somewhere I might read further on this?
  2. If not, does my attempted solution sound like a reasonable approach? If so, do you have an idea of how I might represent the sub-graph for determining the set of edge pairs resulting in the minimum accumulative angular distance for each vertex?
  3. If not, can you recommend an approach I might be able to take to make progress on solving the previously mentioned Problem?

Any advice appreciated!

Angular 7 child routes import component usando modules


Estou tentando setar algumas rotas filhas na minha aplicação angular 7 porém elas não funcionam, tenho o seguinte cenário:

Possuo um base-home.component e um home.component, encapsulei os dois components em modules específicos de cada um, base-home.module e home.module, importei os dois módulos no app.module, e setei no app-routing.module umas rota '/' que chama o base-home.component, e uma rota filha '/home' que chama o home.component, porém ele não carrega a página, porém se eu importar os components direto no app.module em vez de importar os modules eles funciona, segue como estão os arquivos:

// app.module.ts  import { BrowserModule } from '@angular/platform-browser'; import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core';  import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component';  import { HomeModule } from './home/home.module'; import { BaseHomeModule } from './base-home/base-home.module';  @NgModule({   declarations: [     AppComponent   ],   imports: [     BrowserModule,     CommonModule,     AppRoutingModule,     BaseHomeModule,     HomeModule   ],   providers: [],   bootstrap: [AppComponent] }) export class AppModule { }  
// app-routing.module.ts  import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router';  import { HomeComponent } from './home/home.component'; import { BaseHomeComponent } from './base-home/base-home.component';  const routes: Routes = [   {     path: '',     component: BaseHomeComponent,     children: [       {         path: 'home',         component: HomeComponent        }     ]   } ];  @NgModule({   imports: [RouterModule.forRoot(routes)],   exports: [RouterModule] }) export class AppRoutingModule { }  
// base-home.module.ts  import { NgModule } from '@angular/core';  import { BaseHomeComponent } from './base-home.component';  @NgModule({   declarations: [       BaseHomeComponent   ],   exports: [       BaseHomeComponent     ] }) export class BaseHomeModule {}  
// home.module.ts  import { NgModule } from '@angular/core';  import { HomeComponent } from './home.component';  @NgModule({   declarations: [       HomeComponent   ],   exports: [       HomeComponent     ] }) export class HomeModule { }  

Dessa maneira acima ele não funciona, mas se eu importar o base-home.component direto no no app.module ele funciona, dessa forma:

// app.module.ts  import { BrowserModule } from '@angular/platform-browser'; import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core';  import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component';  import { HomeModule } from './home/home.module'; import { BaseHomeComponent } from './base-home/base-home.component';  @NgModule({   declarations: [     AppComponent,     BaseHomeComponent   ],   imports: [     BrowserModule,     CommonModule,     AppRoutingModule,     HomeModule   ],   providers: [],   bootstrap: [AppComponent] }) export class AppModule { }  

Alguém sabe como eu posso fazer as child routes funcionar importando apenas os modules com os components encapsulados sem precisar importar o component direto no app-module ?

Problemas con guard en angular 7

La verdad es que soy nuevo en esto de angular. tengo dificultades con los guard ya que no he podido crear uno para poder crear un login en la web app que estoy desarrollando. si alguien me puede facilitar un ejemplo que sea claro de un login en angular 7. ya que hace dias coloque mi problema pero nadie pudo darme informacion de esto.

Angular Firebase, erro: “Cannot read property ‘displayName’ of undefined”

meu app.component.html:

<nav class="navbar navbar-expand-sm bg-light"> <ul class="navbar-nav">   <li class="nav-item">     <a class="nav-link" routerLink=''>Home</a>   </li>   <li *ngIf='!user' class="nav-item">     <a class="nav-link" routerLink='login'>Login</a>   </li>   <li *ngIf='user' class="nav-item">     <a class="nav-link" routerLink='login' (click)='logout()'>Logout</a>   </li>   <li class="nav-item">     <a class="nav-link">--</a>   </li>   <h3 class="user-display">{{ user.displayName }}</h3> </ul> 

e o typescript:

import { Component } from '@angular/core'; 

import { AngularFireAuth } from ‘@angular/fire/auth’; import * as firebase from ‘firebase’;

@Component({ selector: ‘app-root’, templateUrl: ‘./app.component.html’, styleUrls: [‘./app.component.css’] }) export class AppComponent { user: firebase.User;

constructor(private afAuth: AngularFireAuth) { afAuth.authState.subscribe(user => this.user = user); }

logout() { this.afAuth.auth.signOut(); } }

HTTP.Get Angular

Usando el servicio POSTMAN puedo llamar al servicio sin problemas(este servicio usa GET y RAW)

Tengo mi controlador:

var headers = {headers: new  HttpHeaders({ 'Content-Type': 'application/json; charset=utf-8'})}; var object = JSON.stringify(test)  TestService.calculate(object, headers).then(       function(d) {           console.log(d)       } ); 

Mi servicio:

calculateCorrelation : function(object, options) {     return $  http.get(URL, object, options, {         params : {}     }).then(function(response) {             return response.data;     }, function(errResponse) {             return $  q.reject(errResponse);     }); }, 

Pero tengo este error: Error: HttpHeaders is not defined, mirando tengo que importar esto:

import { HttpClient, HttpHeaders } from '@angular/common/http'; 

Pero no se exactamente donde colocarlo para que no me de error

API Twitter MEAN stream Node, Mongo y Angular

He instalado recientemente un NPM de Twitter en node, lo cierto es que funciona bastante bien, y realiza las tareas de la API corretamente, pero, en consola, ahora viene el momento donde quiero almacenar y mostrar más tarde en ángular en un formato que vaya apareciendo los mensajes en directo.

Para ello he revisado la información del post: Twitter streaming API para NodeJs Y como os comento funciona muy bien en consola.

La documentación que estoy utilizando es la siguiente: https://developer.twitter.com/en/docs/tweets/filter-realtime/api-reference/post-statuses-filter.html

El código que utilizo para que se vea correctamente en la consola es el siguiente:

client.stream('statuses/filter', {track: '@el_pais'}, function(stream) {   stream.on('data', function(event) { console.log(event && event.text);   });    stream.on('error', function(error) {     throw error;   }); }); 

Y el código en el cual estoy trabajando es el siguiente:

twitterperfilesCtrl.streamPerfiles = async(req, res) =>{ const twitterPerfiles = await twitterPerfil.find(); const contadorPerfiles = await twitterPerfil.countDocuments();  for( var i = 0; i < contadorPerfiles; i++){     if(twitterPerfiles[i].id){         var track = { screen_name: twitterPerfiles[i].screen_name };         client.stream('statuses/filter', {track}, function(stream) {             stream.on('data', function(event) {                 console.log(event && event.text);             });              stream.on('error', function(error) {                 throw error;             });         });     } } res.json(event.text); } 

Con mi código lo que pretendo es que recorra todos los perfiles que tengo para que se almacenen todos los mensajes que se publican de cada perfil y a su vez posteriormente se publiquen en ángular.

El problema con el que me encuentro es que con este código me aparece un error de Status Code: 406 entiendo que este código aparece por que el formato en el que se está devolviendo los datos no es el correcto, eso es lo que entiendo pero no sé si realmente van por ahí los tiros

How to create a json file and Upload it via POST using Angular

Hi i know this is not entirely code related but i need to know how to approach for this kind of problem

Description: i need to create a json file in which i had to write data in it and then using the post request i need to send it . here i need clarity/suggestoion on below point

  1. How can we create a json file (if not we can keep a json file in assets folder)
  2. How can we write to a json file (assestsfolder) or any other
  3. How can we send that json file via post request

Adicionar botão de instalar site pwa angular

Estou tentando implantar o PWA em um projeto angular v6.

Eu fiz o comando dentro do meu projeto:

ng add @angular/pwa@v6-lts 

Ele adicionou vários arquivos no meu projeto, como a pasta com icones e manifesto, porém, quando eu dou ng serve e acesso pelo navegador do celular, não é aberto o prompt perguntando se desejo instalar. Alguém sabe me dizer se existe algum procedimento a mais que é necessário fazer pra abrir aquele prompt? Ele roda através do ng serve ou essa funcionalidade só funciona no build?