Html 工具栏视图的数据更改时是否未更改?
这是我的示例代码: 加价:Html 工具栏视图的数据更改时是否未更改?,html,angular,typescript,toolbar,Html,Angular,Typescript,Toolbar,这是我的示例代码: 加价: <div> <ejs-toolbar #element> <e-items> <e-item *ngFor="let item of newarray; let i = index" [text]="item.text" [tooltipText]="item.text"> </e-item> </e-items> </ejs-toolbar
<div>
<ejs-toolbar #element>
<e-items>
<e-item *ngFor="let item of newarray; let i = index" [text]="item.text" [tooltipText]="item.text">
</e-item>
</e-items>
</ejs-toolbar>
</div>
<div>
<div style="margin-top: 5px">
<button style="margin-right: 5px" (click)="run()" type="submit">add</button>
</div>
</div>
<div>
<pre>newarray: {{ newarray | json }}</pre>
</div>
import {
Component, OnInit, ViewChild, ElementRef
} from '@angular/core';
import { ToolbarComponent } from '@syncfusion/ej2-ng-navigations';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
@ViewChild('element') el: ToolbarComponent;
newarray: Array<any>;
ngOnInit() {
this.newarray = [
{ text: "Cut" },
{ text: "Copy" },
{ text: "Paste" },
{ text: "Underline" },
]
}
run() {
let ummy: Array<any> = [
{ text: "Paste" },
{ text: "Underline" },
{ text: "Italic" }]
this.el.items = ummy
}
}
这里有我的工具栏组件。它通过*ngfor
呈现。如果我更改了它的数据,工具栏视图不会更新,但数据正在更改
我不知道,怎么解决这个问题
请为此提供合适的解决方案。谢谢试试这样的方法: 使用工具栏组件 演示------> TS:
导入{
组件、OnInit、ViewChild、ElementRef
}从“@angular/core”开始;
从“@syncfusion/ej2 ng导航”导入{ToolbarComponent};
@组成部分({
选择器:“我的应用程序”,
templateUrl:“./app.component.html”,
样式URL:['./app.component.css']
})
导出类AppComponent实现OnInit{
@ViewChild(“元素”)el:Toolbar组件;
新数组:数组;
恩戈尼尼特(){
this.newarray=[
{文本:“剪切”},
{文本:“复制”},
{文本:“粘贴”},
{文本:“下划线”},
]
}
运行(){
让ummy:Array=[
{文本:“粘贴”},
{文本:“下划线”},
{文本:“斜体”}]
this.el.items=ummy
}
}
尝试以下方法:
使用工具栏组件
演示------>
TS:
导入{
组件、OnInit、ViewChild、ElementRef
}从“@angular/core”开始;
从“@syncfusion/ej2 ng导航”导入{ToolbarComponent};
@组成部分({
选择器:“我的应用程序”,
templateUrl:“./app.component.html”,
样式URL:['./app.component.css']
})
导出类AppComponent实现OnInit{
@ViewChild(“元素”)el:Toolbar组件;
新数组:数组;
恩戈尼尼特(){
this.newarray=[
{文本:“剪切”},
{文本:“复制”},
{文本:“粘贴”},
{文本:“下划线”},
]
}
运行(){
让ummy:Array=[
{文本:“粘贴”},
{文本:“下划线”},
{文本:“斜体”}]
this.el.items=ummy
}
}
尝试访问完整的元素属性,这将有助于理解Thankyu。尝试访问完整的元素属性,这将有助于理解Thankyu。
import {
Component, OnInit, ViewChild, ElementRef
} from '@angular/core';
import { ToolbarComponent } from '@syncfusion/ej2-ng-navigations';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
@ViewChild('element') el: ToolbarComponent;
newarray: Array<any>;
ngOnInit() {
this.newarray = [
{ text: "Cut" },
{ text: "Copy" },
{ text: "Paste" },
{ text: "Underline" },
]
}
run() {
let ummy: Array<any> = [
{ text: "Paste" },
{ text: "Underline" },
{ text: "Italic" }]
this.el.items = ummy
}
}