小编Ham*_*dad的帖子

在字符串 Angular 的一部分上应用粗体文本

我想让我的文字的一部分加粗。

我从特定文件中获取文本。

"INFORMATION": "Here's an example of text",

我希望这Here's an是大胆的。

"INFORMATION": "<b>Here's an</b> example of text",

"INFORMATION": "<strong>Here's an</strong> example of text"

然后我打印

<span translate>INFORMATION</span>
Run Code Online (Sandbox Code Playgroud)

而不是得到

这是一个文本示例

我得到

<b>Here's an</b> example of text
Run Code Online (Sandbox Code Playgroud)

或者

<strong>Here's an</strong> example of text
Run Code Online (Sandbox Code Playgroud)

更新

我正在尝试innerHTML

<span [innerHTML]="information | translate"></span>
Run Code Online (Sandbox Code Playgroud)

信息是包含文本的变量

但它忽略了我的 html 标签,它只打印文本

html javascript ngx-translate angular

8
推荐指数
2
解决办法
2万
查看次数

右文本对齐垫 - 扩展 - 面板材料组件

我会将mat-expansion-panel组件的描述文本对齐到右边

我试图使用对齐文本,但没有任何改变这是我的HTML

<mat-expansion-panel>
    <mat-expansion-panel-header>
      <mat-panel-title>
        Cycle ingénieur en informatique
      </mat-panel-title>
      <mat-panel-description>
        2014-2017
      </mat-panel-description>
    </mat-expansion-panel-header>
    ....
  </mat-expansion-panel>
Run Code Online (Sandbox Code Playgroud)

CSS:

mat-panel-description {
    text-align: right;
}
Run Code Online (Sandbox Code Playgroud)

这是实际行为

例

我希望2014年的这段时间能够保持正确.

html css angular-material angular

7
推荐指数
3
解决办法
6271
查看次数

使用PrimeNG自动完成组件显示对焦点的建议

当用户单击输入字段时,我将自动显示建议。

目前,仅当用户输入字符时才显示建议。

<p-autoComplete [formControl]="control.controls.EJ_Id_Name" 
  [suggestions]="results" 
  (completeMethod)="search($event,'EJ')" 
  emptyMessage={{noResult}} 
  [autoHighlight]="true">
</p-autoComplete>
Run Code Online (Sandbox Code Playgroud)

我试图添加(onFocus)并传递给它search($event,'EJ')

这是我的搜索功能:

search(event, type) {
    this.searchRmpmService.getResults(event.query, type).then(data => {
        console.log(event);
        if(event.query){
            this.results = this.filterResults(event.query, data);
            console.log(this.results)
        }
        else {

            this.results = ["onfocus"];
            console.log(this.results) // I get "onfocus" on my devtool browser when I focus on the input            }

    });
}
Run Code Online (Sandbox Code Playgroud)

onFocus()没有显示建议列表,我想应该打电话给 我(completeMethod)onFocus但我不知道怎么办?

primeng angular

5
推荐指数
2
解决办法
4014
查看次数

无法将角度更新为版本6

我正在尝试将角度更新为最新版本.

我更新了global @ angular/cli

npm install -g @angular/cli
Run Code Online (Sandbox Code Playgroud)

然后,当我尝试更新local @ angular/cli时,ng update @angular/cli我收到此错误:

Error: Unexpected end of JSON input
Unexpected end of JSON input
Run Code Online (Sandbox Code Playgroud)

这是我的package.json

{
  "name": "apimap",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^5.2.11",
    "@angular/cdk": "^5.2.5",
    "@angular/common": "^5.2.11",
    "@angular/compiler": "^5.2.11",
    "@angular/core": "^5.2.11",
    "@angular/flex-layout": "^2.0.0-rc.1",
    "@angular/forms": "^5.2.11",
    "@angular/http": "^5.2.11",
    "@angular/material": "^5.2.5",
    "@angular/platform-browser": "^5.2.11",
    "@angular/platform-browser-dynamic": "^5.2.11", …
Run Code Online (Sandbox Code Playgroud)

node.js npm typescript angular angular6

5
推荐指数
1
解决办法
4685
查看次数

Angular 中多个相同的异步管道导致多个 http 请求

在我的 angular 应用程序中,我使用异步管道多次渲染组件

<app-main-chart  [type]="type" [name]="Name" [values]="values$ | async" [objectifs]="dataObjectifs"></app-main-chart>
...
...
<app-main-chart  [type]="type" [name]="Name" [values]="values$ | async" [objectifs]="dataObjectifs"></app-main-chart>
Run Code Online (Sandbox Code Playgroud)

问题是导致多个http请求。

如何只使用一个请求?

rxjs angular

5
推荐指数
1
解决办法
614
查看次数

角度材质按钮未呈现

我已经按照步骤安装材料设计,但是当我添加按钮时,我没有得到 MD 样式。

<button mat-button [matMenuTriggerFor]="menu">Menu</button>
    <mat-menu #menu="matMenu">
      <button mat-menu-item>Item 1</button>
      <button mat-menu-item>Item 2</button>
</mat-menu>
Run Code Online (Sandbox Code Playgroud)

Package.json 文件

{
  "name": "apimap",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^5.0.2",
    "@angular/cdk": "github:angular/cdk-builds",
    "@angular/common": "^5.0.0",
    "@angular/compiler": "^5.0.0",
    "@angular/core": "^5.0.0",
    "@angular/forms": "^5.0.0",
    "@angular/http": "^5.0.0",
    "@angular/material": "github:angular/material2-builds",
    "@angular/platform-browser": "^5.0.0",
    "@angular/platform-browser-dynamic": "^5.0.0",
    "@angular/router": "^5.0.0",
    "core-js": "^2.4.1",
    "hammerjs": "^2.0.8",
    "rxjs": "^5.5.2",
    "zone.js": "^0.8.14"
  },
  "devDependencies": …
Run Code Online (Sandbox Code Playgroud)

css angular-material angular

4
推荐指数
1
解决办法
4187
查看次数

向右浮动时无法点击按钮

我创建了一个使用添加和删除按钮动态添加输入的表单.我会把它们放在右边

我不能点击删除按钮来执行一个lastet

这里有一个例子

HTML文件:

    <mat-step [stepControl]="secondFormGroup">
    <form [formGroup]="secondFormGroup">
        <ng-template matStepLabel>Constituez votre équipe</ng-template>
        <div formArrayName="pers" *ngFor="let control of secondFormGroup.controls.pers.controls; let i= index">
            <mat-form-field>
                <input matInput placeholder="Nom collaborateur #{{i+1}}" [formControl]="control.controls.name" required>
            </mat-form-field>
            <mat-form-field>
                <input matInput placeholder="Poste" [formControl]="control.controls.poste" required>
            </mat-form-field>
            <button *ngIf="secondFormGroup.controls.pers.controls.length > 1" (click)="deleteItem()" mat-mini-fab color="warn" class="rightButton"><mat-icon >remove</mat-icon>
                </button>
        </div>
        <div>{{secondFormGroup.value | json}}</div>


        <button (click)="addItem()" mat-mini-fab color="primary" class="rightButton"><mat-icon >add</mat-icon>
              </button>
    </form>
</mat-step>
Run Code Online (Sandbox Code Playgroud)

CSS文件:

.rightButton {
    position: relative;
    float: right;
}
Run Code Online (Sandbox Code Playgroud)

当我rightButton在删除按钮上禁用类时,我可以单击所有按钮而不会出现问题,但它们并不是我想要的正确位置.

css angular

3
推荐指数
1
解决办法
2439
查看次数

使用 Express 从 Firebase 数据库中获取数据

我想从 Firebase 数据库中检索数据。

我已经像这样初始化了我的server.js

var http = require("http");

var firebase = require("firebase");
var express = require("express");
var app = express();
var routerProj = require("./routes/routes");
var bodyParser = require("body-parser");
var port = 8080; // set our port
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
var server = app.listen(port);

app.use(bodyParser.json());
var config = {
  apiKey: "XXXXXXXXXXXXXXXX",
  authDomain: "datatable-18f93.firebaseapp.com",
  databaseURL: "https://datatable-18f93.firebaseio.com",
  projectId: "datatable-18f93",
  storageBucket: "datatable-18f93.appspot.com",
  messagingSenderId: "282475200118"
};
const db = firebase.initializeApp(config);
app.use("/v1", routerProj);

console.log("Server running at http://127.0.0.1:8000/");
module.exports.db = db.database(); //this doesnt …
Run Code Online (Sandbox Code Playgroud)

javascript node.js express firebase firebase-realtime-database

3
推荐指数
1
解决办法
7000
查看次数

使用 Material 数据表时 dataSource.connect 不是函数

我将使用 dataSource 作为数组的材料数据表。

import { Component, OnInit } from '@angular/core';
import { MatTableDataSource } from '@angular/material';
import { AjouttextService } from '../ajouttext.service';
import { DataSource } from "@angular/cdk/collections";
import { Observable } from "rxjs/Observable";
import { nomchamp } from '../model';

@Component({
  selector: 'app-datatable',
  templateUrl: './datatable.component.html',
  styleUrls: ['./datatable.component.css']
})
export class DatatableComponent implements OnInit {

  constructor(private dataService: AjouttextService) { }
  data: nomchamp[] = [{ id: "33", text: "HAHA" }, { id: "55", text: "bzlblz" }];

  displayedColumns = ['text'];
  dataSource = this.data; …
Run Code Online (Sandbox Code Playgroud)

angular-material angular-datatables angular-material2 angular

2
推荐指数
1
解决办法
7457
查看次数

使用百分比定义垫卡标题宽度

我将中心垫标题文本。因此,我需要将宽度设置为100%,但只有使用“ px”时,我才不会得到结果。

因此,我尝试对所有父母容器设置宽度,但没有结果。

这是我的html文件

<div Fxlaout="row" fxLayoutGap="20px" class="container">
    <div fxFlex=30>
        <mat-card>
            <mat-card-header>
                <mat-card-title>Collaborateurs sur ce projet</mat-card-title>
            </mat-card-header>
            <mat-card-content>

                <mat-list role="list" *ngFor="let per of Projet?.pers">
                    <mat-list-item role="listitem">Nom : {{per.name}}</mat-list-item>
                    <mat-list-item role="listitem">poste : {{per.poste}}</mat-list-item>
                </mat-list>
            </mat-card-content>
        </mat-card>
    </div>
    <div fxFlex>
        <mat-card>
            <mat-card-header>
                <mat-card-title>Les fonctionnalités du produit</mat-card-title>
            </mat-card-header>
            <mat-card-content>
                <mat-list role="list" *ngFor="let func of Projet?.backlog.fonctionnalite; let i=index">
                   <mat-list-item role="listitem">Fonctionnalité #{{i}} : {{func.fonctionnalite}}</mat-list-item>
                </mat-list>
            </mat-card-content>
         </mat-card>
    </div>
</div> 
Run Code Online (Sandbox Code Playgroud)

CSS文件

  mat-card {
    margin-top: 20px;
    margin-bottom: 20px;
    padding: 0;
    width: 100%;
  }
  mat-card-header {
    background-color: #116a94; …
Run Code Online (Sandbox Code Playgroud)

html css angular-material2 angular md-card

1
推荐指数
1
解决办法
3726
查看次数