4-24 1,422 views
zone.js Cannot read property 'apply' of undefined

Uncaught TypeError: Cannot read property 'apply' of undefined
at XMLHttpRequest.desc.get [as ontimeout] (zone.js:1265)
at XHRLocalObject.AbstractXHRObject._cleanup (abstract-xhr.js:149)
at XMLHttpRequest.xhr.onreadystatechange (abstract-xhr.js:125)
at XMLHttpRequest.wrapFn (zone.js:1230)
at ZoneDelegate.invokeTask (zone.js:398)
at Zone.runTask (zone.js:165)
at XMLHttpRequest.ZoneTask.invoke (zone.js:460)
解决方法:
npm install zone.js@0.8.5 --save
Angular2 no provider for NameService
/// <reference path="../typings/angular2/angular2.d.ts" />
import {Component,View,bootstrap,NgFor} from "angular2/angular2";
import {NameService} from "./services/NameService";
@Component({
selector:'my-app',
injectables: [NameService]
})
@View({
template:'<h1>Hi {{name}}</h1>' +
'<p>Friends</p>' +
'<ul>' +
' <li *ng-for="#name of names">{{name}}</li>' +
'</ul>',
directives:[NgFor]
})
class MyAppComponent
{
name:string;
names:Array<string>;
constructor(nameService:NameService)
{
this.name = 'Michal';
this.names = nameService.getNames();
}
}
bootstrap(MyAppComponent);
解决方法:
You have to use providers instead of injectables
@Component({
selector: 'my-app',
providers: [NameService]
})
项目URL为 http://127.0.0.1:4200/admin/index.html 如何发布
ng build --base-href admin
或者修改index.html中的base
<base href="admin">
发送二进制数据
let sb = req.serializeBinary();
return this.http
.post(this.apiurl, this.toArrayBuffer(sb), {headers: this.headers})
.toPromise()
.then(res => this.convertBlob(res.totalBytes))
.catch(this.handleError);
private toArrayBuffer (data: Uint8Array) : ArrayBuffer{
if (data == null){
return null
}
let ab = new ArrayBuffer(data.length);
let u8 = new Uint8Array(ab);
for(var i = 0; i < data.length; i++){
u8[i] = data[i];
}
return ab
}
接收二进制数据
接收不了,接收到的数据都是错的
Very nice depth 😮 http://www.sharetimemagazine.com/index.php?option=com_k2&view=itemlist&task=user&id=456532