我正在学习 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 { }
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";
  }
}
测试组件.html
<h1>Hello {{name}}</h1>
<button (click)="changeName()">Click me!</button>
这是主要的 index.html
<!DOCTYPE …我不能让进度条工作!如果我执行以下代码,即使代码被执行,条形仍然为空,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, …我正在尝试理解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;
}
现在,第一个元素正确打印,而第二个元素是垃圾.我知道我可以使用:
address = (address + 1);
为了将指针移动到数组的第二个元素,但我不明白为什么第一个方法是错误的.