RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题

问题[angular5]

Martin Hope
Nevega
Asked: 2020-10-21 05:50:00 +0000 UTC

从服务更新不同组件中的数据

  • 0

有 2 个组件 A 和 B,以及一个具有“获取数据”和“更新数据”两个功能的服务在数据库中。两个组件都使用数据模型,服务注册在公共模块中。更新数据库中的数据后如何在两个组件中获取更新的模型。? 那些。如何强制完成接收数据的功能?

angular5
  • 1 个回答
  • 10 Views
Martin Hope
Ara Chinaryan
Asked: 2020-08-23 17:11:28 +0000 UTC

Angular 6 创建带有内容的标签

  • 0

我有条件在id="confirm_Password"创建或删除span包含内容的元素后,但这是使用完成的Jquery,您可以帮助将其转换为干净的typescript

if (data['password'] == data['confirm_Password']) {
                    $('.confirm_Password_message').remove();
                } else {

                     $('<span class="confirm_Password_message">Passwords do not match</span>').insertAfter($('#confirm_Password'));
                }

形式

config: FieldConfig[] = [
        {
            type: 'textarea',
            label: 'Description',
            name: 'description',
            placeholder: 'Description',
            value: '',
            validation: [
                {
                    name: 'required',
                    validator: Validators.required,
                    message: 'Description Required'
                }
            ]
        },
        {
            type: 'checkbox',
            label: 'Status',
            name: 'status',
            value: ''
        },
        {
            label: 'Submit',
            name: 'submit',
            type: 'button',
        }
    ];

表单html

<div class="modal-body">
        <app-dynamic-form #form="appDynamicForm" (submit)="formSubmitted($event)" [config]="config"></app-dynamic-form>
        <button type="button" class="btn btn-default float-right mr-2"  (click)="hideModal()">Close</button>
      </div>
angular5
  • 2 个回答
  • 10 Views
Martin Hope
Данис Хамидуллин
Asked: 2020-08-17 22:00:26 +0000 UTC

Angular,无需重新加载即可更新组件

  • 0

一页上有几个routerLink,导致notes/:id:

routerLink="notes/1"
routerLink="notes/2"
routerLink="notes/3"
...

在同一个父组件中,该组件被<router-outlet></router-outlet>加载NoteView,它id查找并显示信息。在地址栏中的链接之间切换时id,组件会更改但不会重新加载,会与第一个id打开的链接挂起。每次单击不同的链接时,如何强制组件更新?Event在每次点击链接的时候,EventListner会不会太麻烦的解决方案,会有几个这样的组件。

路线是这样的:

const routes: Routes = [
  {
    path: '',
    component: HomeComponent
  },
  {
    path: 'app',
    component: TodoAppParentComponent,
    children: [{
      path: 'notes',
      children: [{
        path: ':id', // id в ссылке меняется но компонент остается неизменным
        component: NoteViewComponent
      }]
    }]
  }
];

问题组件类

export class NoteViewComponent implements OnInit {

  id: string = null;
  note: object = null;

  constructor(
    private http: HttpService,
    private activatedRoute: ActivatedRoute
  ) { }

  ngOnInit() {
    this.id = this.activatedRoute.snapshot.params['id']; // не срабатывает при переходе по разным routerLink, как сделать чтоб срабатывал?
    this.note = {
      title: 'Пример заголовка, заметка',
      body: `lorem....`
    };
  }
}

HTML 组件模板

<p>
  id: {{id}}
</p>
<div *ngIf="note">
  <h3>{{note.title}}</h3>
  <hr>
  <div class="body" innerHTML="{{note.body}}"></div>
</div>

屏幕 在 URL id=2 中,但组件剩下 1

angular5
  • 1 个回答
  • 10 Views
Martin Hope
Kris_tina
Asked: 2020-08-13 17:08:29 +0000 UTC

获取存储在值 mat-list-option 中的值,角度材料 5

  • 0

使用 Angular Material 5.2.4(客户端的选择列表组件)从客户端向服务器发送数据时出现问题。事实上,一个带有名称和 id 的复选框列表。因此,我无法将检查的 id 值数组发送到服务器,因为 浏览器仅对检查 MatListOption 做出反应,而由 id 组成的值本身,我无法从中获取。
这是component.html程序代码

<mat-selection-list 
(selectionChange)="onSelection($event.source.selectedOptions.selected)" >
<mat-list-option *ngFor="let car of cars" [value]="car.id" 
checkboxPosition="before" >
{{car.description}}
</mat-list-option>
</mat-selection-list>

组件.ts

 import { Component, OnInit } from '@angular/core';
 import { ListService } from '../list.service';

@Component({
  selector: 'app-list-measu',
  templateUrl: './list-measu.component.html',
  styleUrls: ['./list-measu.component.css']
})
export class ListMeasuComponent implements OnInit {
    cars: Array<any>;
    current_selected: string;
    id: Array<any> = new Array<any>();


  constructor(private listService: ListService) { }

  ngOnInit() {
      this.listService.getAllmeasures().subscribe(data => {
      this.cars = data;
    });
  }

  onSelection(e){
    console.log(e);       
    });

谢谢您的帮助!)

angular5
  • 1 个回答
  • 10 Views
Martin Hope
Aleksey exec
Asked: 2020-07-24 23:37:37 +0000 UTC

如何使用 ngFor 仅显示前 4 个项目

  • 1

items数组中有 10 个对象,我只需要使用 size 变量显示前 4 个对象

app.component.html

<div class="prod-section">
  <div  *ngFor="let item of items">
    <h1>{{ item.id }}</h1>
    <p>{{ item.name }}</p>
  </div>
</div>

app.component.ts

  size: number = 4;

  items = [
      { id: 1, name: 'плитка' },
      { id: 2, name: 'плитка' },
      { id: 3, name: 'плитка' },
      { id: 4, name: 'плитка' },
      { id: 5, name: 'плитка' },
      { id: 6, name: 'плитка' },
      { id: 7, name: 'плитка' },
      { id: 8, name: 'плитка' },
      { id: 9, name: 'плитка' },
      { id: 10, name: 'плитка' },
  ];
angular5
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5