我在Angular 2 app(beta 1)中有一个ComponentB.它完全正常,直到我将它放在ComponentA中的ngFor循环中.我收到了相当神秘的错误:
EXCEPTION:TypeError:viewFactory_ComponentB0不是[ComponentA @ 1:23中的数字]中的函数BrowserDomAdapter.logError @ angular2.dev.js:22690BrowserDomAdapter.logGroup @ angular2.dev.js:22701ExceptionHandler.call @ angular2.dev.js:1163 (匿名函数)@ angular2.dev.js:12416NgZone._notifyOnError @ angular2.dev.js:13324collection_1.StringMapWrapper.merge.onError @ angular2.dev.js:13228run @ angular2-polyfills.js:141(匿名函数)@ angular2 .dev.js:13247NgZone.run @ angular2.dev.js:13209(匿名函数)@ angular2.dev.js:12499schedulerFn @ angular2.dev.js:12742tryCatcher @ Rx.js:31Subscriber.next @ Rx.js:9500Subject ._next @ Rx.js:9999Subject.next @ Rx.js:9963EventEmitter.emit @ angular2.dev.js:12723(匿名函数)@ angular2.dev.js:13140run @ angular2-polyfills.js:138NgZone._notifyOnTurnDone @ angular2 .dev.js:13139(匿名函数)@ angular2.dev.js:13254zoneBoundFn @ angular2-polyfills.js:111lib $ es6 $ promise $ asap $$ flush @ angular2-polyfills.js:1305 angular2.dev.js:22690 ORIGINAL EXCEPTION:TypeError:viewFactory_ComponentB0不是functionBrowserDomAdapter.logError @ angular2.dev.js:22690ExceptionHandler.call @ angular2.dev.js:1172(匿名函数)@ angular2.dev.js:12416NgZone._notifyOnError @ angular2. dev.js:13324collection_1.StringMapWrapper.merge.onError @ angular2.dev.js:13228run @ angular2-polyfills.js:141(匿名函数)@ angular2.dev.js:13247NgZone.run @ angular2.dev.js:13209(匿名函数)@ angular2.dev.js:12499schedulerFn @ angular2.dev.js:12742tryCatcher @ …
我试图使用jsplumb来显示两个组件之间的连接.
我最终做的是使用jQuery来获取UI元素的句柄并使用它来渲染连接,使用jsplumb库.如下:
JsPlumb配置
if( typeof jsPlumb !== 'undefined' && jsPlumb !== null ) {
jsPlumb.ready(function() {
jsPlumb.deleteEveryEndpoint();
jsPlumb.setContainer(this._container);
jsPlumb.Defaults.PaintStyle = { strokeStyle:'#339900', lineWidth:2, dashstyle: '3 3'};
jsPlumb.Defaults.EndpointStyle = { radius:7, fillStyle:'#339900' };
jsPlumb.importDefaults({
Connector : [ 'Flowchart', { curviness:0 } ],
ConnectionsDetachable:true,
ReattachConnections:true
});
jsPlumb.endpointClass = 'endpointClass';
jsPlumb.connectorClass = 'connectorClass';
});
}
Run Code Online (Sandbox Code Playgroud)
Js-Plumb用法
jsPlumb.connect({
source: $('#'+entityFrom+'Panel'),
target: $('#'+entityTo+'Panel'),
anchors: ['RightMiddle', 'LeftMiddle']
});
Run Code Online (Sandbox Code Playgroud)
从angular2上的各种博客,我明白使用带有ng2的jQuery是一种反模式.
某些人可以提供替代或更好的设计方法来使用带有angular2或任何其他类似库的jsPlumb.
我们有一个带有IIS网站和下面的IIS Web应用程序的Web服务器.Web应用程序的根目录是:http:// website/webapplication /.部署后,我在浏览器中收到以下错误:
http://website/app/app.component.html 404(未找到)
app/app.component.html 404(未找到)
我的组件:
@Component({
selector: "app",
templateUrl: "./app/app.component.html"
})
Run Code Online (Sandbox Code Playgroud)
文件app.component.html确实不存在于/app/app.component.html下,但确实存在于:/webapplication/app/app.component.html.
所以,我的结论是Angular仅在网站的根目录中有效.在html标题中,我将标记设置为:<base href="/webapplication/">,但这没有帮助.
这似乎是一个正常的设置,我无法相信在Angular中解析的模板失败,我必须遗漏一些东西......有谁知道解决这个问题?
我正在寻找一种方法来告诉Angular在包含标记的表达式中显示一个值,并实际使用HTML:
{{ value }}
let value = "<span>foobar</span>";
Run Code Online (Sandbox Code Playgroud)
因此,value变量包含带有标记的字符串,我想应用标记,以便在页面中呈现它.因此,如果value包含<b>test</b>,则在页面上将显示粗体文本.
我一直在尝试用Angular2实现一个简单的ngFor,但我不知道导致错误的错误'Generic TYpe Array需要一个参数.喜欢
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl:'./app.component.html',
})
export class AppComponent {
clients:Array;
doctors:Array;
constructor(){
this.clients=["Client1", "Client2", "Client3"];
this.doctors=["Doctor1","Doctor2","Doctor3"];
}
}
Run Code Online (Sandbox Code Playgroud) angular2-directives angular2-template angular2-components angular
我有一个枚举,
并希望从模板传递枚举值。这怎么可能?
export enum FIELDS {
GENDER = <any>'Gender',
SALUTATION = <any>'Salutation',
FIRSTNAME = <any>'First Name',
LASTNAME = <any>'Last Name',
EMAIL_ADDRESS = <any>'Email Address',
COUNTRY = <any>'Country',
}
Run Code Online (Sandbox Code Playgroud)
我的模板。在这里我想传递枚举值
[ngClass]="{'error':validate(FIELDS.COUNTRY)}"
Run Code Online (Sandbox Code Playgroud)
//这将引发错误:无法获取未定义或空引用的属性COUNTRY。
我的组件:
@Component({
selector: 'row-general',
template: require('./modify-invalid-row-general.component.html'),
styleUrls: ['./app/nedit/modify-invalid-row/modify-invalid-row.component.css']
})
export class ModifyInvalidRowGeneralComponent {
@Input() row: UploadRow;
@Input() columns: ConfigColumn[];
@Output() validateRow = new EventEmitter<UploadRow>();
public validate(field: string): boolean {
let invalidFields: string[] = [];
if (this.row.invalidFields != null)
invalidFields = this.row.invalidFields.split(';');
for (let i = 0; i < invalidFields.length; …Run Code Online (Sandbox Code Playgroud) 我在LocalStorage和ngOnInit钩子中存储了一些对象,我将这些数据接收到数组,我在模板中显示*ngFor.如何查看LocalStorage中的更改并自动更新视图?
我想从我的角度2 app调用java Api.我使用typescript Map在java app中发送请求.
我在java中的RestEndpoint是这样的:
@PostMapping(value = Constants.PATH_BASE + "/sync/list")
public ResponseEntity<?>configureQueueList(@RequestBody Map<String,Integer> map){
//code here
}
Run Code Online (Sandbox Code Playgroud)
当我尝试使用typescript map时出现此错误:
JSON解析错误:无法从START_ARRAY标记中反序列化java.util.LinkedHashMap的实例; 嵌套异常是com.fasterxml.jackson.databind.JsonMappingException:无法在[来源:java.io.PushbackInputStream@f6b068c;来源:START_ARRAY令牌\n中反序列化java.util.LinkedHashMap的实例.line:1,column:1]
邮差我用这个作为原始的身体,它的工作原理
Run Code Online (Sandbox Code Playgroud){ "key1":"value1", "key2":"value2", ..... ..... }
编辑2: 键入脚本端点
postMap(value:Map<string,number>){
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.http.post(this.url, value, options)
.map(success => success.status)
.catch(this.handleError);
}
Run Code Online (Sandbox Code Playgroud) 我想要类似的东西 class = "myClass {{classVar}}"
我试图在范围内使用变量值来连接类名但不起作用.
<div *ngFor="let classVar of classList" >
<span [ngClass]="'myClass' classVar "></span>
</div>
Run Code Online (Sandbox Code Playgroud) 我想删除使用NgIf无法呈现控件的验证。我试图使用伪指令将其与隐藏控件一起删除,但由于它不在模板中呈现,因此无法执行相同操作。因此,我无法在指令中使用ElementRef来检查formControlName。这是ts文件
this.form = this._fb.group({
text1: ['', Validators.required],
text2: ['', Validators.required]
});
Run Code Online (Sandbox Code Playgroud)
和模板
<form[formGroup]="form">
<input type="text" formControlName="text1">
<div *ngIf="false">
<input type="text" formControlName="text2">
</div>
Run Code Online (Sandbox Code Playgroud)
我想动态且全局地删除text2的验证。不删除ts文件中的验证器。
angular-directive angular2-template angular-validation angular4-forms
angular ×9
typescript ×2
classname ×1
html ×1
html5 ×1
iis ×1
java ×1
javascript ×1
jquery ×1
jsplumb ×1
spring-boot ×1