我有一个Angular组件,它有一个按钮,可以将一个新对象添加到一个充当模型的数组中.在我的组件模板中,我有一个*ngFor循环,它遍历数组中的对象并显示对象属性的输入字段.我还在每个对象旁边有一个"删除"按钮,用于从数组中删除对象.当我执行以下步骤时,UI与模型不同步并清空除第一个项目之外的所有项目的字段.
UI与模型不同步的原因是什么?
这是一个演示问题的Plunker示例示例 我还在模板中添加了一行,显示了模型数组中的内容.
@Component({
selector: 'my-app',
template: `
<div>
<button (click)="things.push({})">+ Add new thing</button>
<br />
<br />
<form #contactForm="ngForm">
<ng-container *ngFor="let thing of things;let i = index">
<input [(ngModel)]="thing.name" name="name-{{i}}" id="name-{{i}}" placeholder="name"/>
<br />
<input [(ngModel)]="thing.otherstuff" name="other-{{i}}" id="other-{{i}}" placeholder="other" />
<button (click)="things.splice(i, 1)">Remove</button>
<br />
<br />
</ng-container>
</form>
{{things | json}}
</div>
`,
})
export class App {
things: Awesome[]
constructor(){
this.things = new Array();
}
}
@NgModule({
imports: [
BrowserModule,
FormsModule …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Google Analytics中的内容分组功能对我的内容进行分组.我的网站有两个主要分组 - "红色产品"和"橙色产品".
在每个分组下,我的产品分为"按压"," 红色产品"和"电动工具"下的"诊断","橙色产品"下的" 锯".
我去了谷歌分析仪表板和管理标签,我创建了两个集团的"红产品"和"橘子产品"与插槽1和2分别.在每个组下的每个页面上,我从我的脚本发送一个"_setPageGroup".对于我的"按下"类别,其下的每个页面都会发送:
_gaq.push(['_setPageGroup', '1', 'Pressing']);
Run Code Online (Sandbox Code Playgroud)
我的"Saws"类别发送了这个:
_gaq.push(['_setPageGroup', '2', 'Saws']);
Run Code Online (Sandbox Code Playgroud)
我在Google Analytics中创建了一个自定义信息中心,我将"红色产品"分组作为维度,将PageViews作为此维度的指标.我为"橙色产品"类别做了同样的事情.我访问了一些页面,过了一段时间我检查了自定义仪表板.它没有对我的内容进行分类.

起初我以为我没有正确发送类别,我决定查看我的Chrome Google Analytics调试器插件.这是它显示的内容:
_gaq.push processing "_setPageGroup" for args: "[1,Pressing]"
Run Code Online (Sandbox Code Playgroud)
调试器插件还显示:
Screen Resolution : 1920x1080
Browser Size : 1899x971
Color Depth : 24-bit
Page Group : 1:Pressing
Cachebuster : 1887104810
Run Code Online (Sandbox Code Playgroud)
我认为这是一个指示器,它正确地将我的"按下"组分类在插槽1下.
为什么它在我的Google Analytics自定义信息中心中没有显示任何内容?更新指标需要多长时间?