小编rek*_*otc的帖子

如何多次重用角度组件

我正在学习 angular 的基础知识,但我仍然无法弄清楚如何在同一个文档中多次重用同一个组件。

这是相关代码:

测试模块.ts

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppComponent }  from './test.component';

@NgModule({
imports:      [ BrowserModule ],
declarations: [ AppComponent ],
bootstrap:    [ AppComponent ]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)

test.component.ts

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

@Component({
    selector: 'example',
    templateUrl: "./test.component.html",
    styleUrls: ["./test-common.css"],
  })

  export class AppComponent  { 

  name = 'Angular'; 

  changeName() {
    this.name = "duck";
  }
}
Run Code Online (Sandbox Code Playgroud)

测试组件.html

<h1>Hello {{name}}</h1>
<button (click)="changeName()">Click me!</button>
Run Code Online (Sandbox Code Playgroud)

这是主要的 index.html

<!DOCTYPE …
Run Code Online (Sandbox Code Playgroud)

javascript components angular

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

backgroundWorker和progressChanged无法正常工作

我不能让进度条工作!如果我执行以下代码,即使代码被执行,条形仍然为空,ReportProgress似乎没有更新任何东西..:

namespace GPUZ_2

{
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();

        GPUZdata test = new GPUZdata
        {
        };

        //invio l'oggetto al thread backgroundworker
        backgroundWorker1.RunWorkerAsync(test);
    }


    private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
    {
        //
        // e.Argument always contains whatever was sent to the background worker
        // in RunWorkerAsync. We can simply cast it to its original type.
        //
        GPUZdata argumentTest = e.Argument as GPUZdata;




        argumentTest.OneValue = 6;
        Thread.Sleep(2000);
        backgroundWorker1.ReportProgress(50);
        argumentTest.TwoValue = 3;
        Thread.Sleep(2000);
        backgroundWorker1.ReportProgress(100);


        //
        // Now, …
Run Code Online (Sandbox Code Playgroud)

c# backgroundworker progress-bar

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

为什么这种方法导航数组错误?

我正在尝试理解C指针,我设置了以下示例:

int main()
{
    int temp[] = {45,67,99};    
    int* address;
    address = &temp[0]; //equivalent to address = temp;
    std::cout << "element 0: " << *address << std::endl;
    address = (address + sizeof(int));
    std::cout << "element 1: " << *address << std::endl;

    std::getchar();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

现在,第一个元素正确打印,而第二个元素是垃圾.我知道我可以使用:

address = (address + 1);
Run Code Online (Sandbox Code Playgroud)

为了将指针移动到数组的第二个元素,但我不明白为什么第一个方法是错误的.

c++ arrays pointers

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