简体   繁体   English

Angular2 Beta 7无限循环

[英]Angular2 beta 7 infinite loop

I get an infinite loop using beta7, this is the Firefox's stacktrace: 我使用beta7遇到了无限循环,这是Firefox的stacktrace:

Error: Script terminated by timeout at:
DebugDomRenderer</DebugDomRenderer.prototype.createText@http:   //localhost:2067/node_modules/angular2/bundles/angular2.dev.js:7184:11
viewFactory_t0@viewFactory_t:256:18
viewFactory_t0@viewFactory_t:266:1
viewFactory_t0@viewFactory_t:266:1
viewFactory_t0@viewFactory_t:266:1
viewFactory_t0@viewFactory_t:266:1
viewFactory_t0@viewFactory_t:266:1
...

Before the jump to beta7 everything works well, but if I switch now to beta6, I get the same error. 跳转到beta7之前,一切都很好,但是如果我现在切换到beta6,则会遇到相同的错误。 So I think the problem was present even before. 所以我认为这个问题甚至在以前就存在。 As you can see in the AppComponent class I'm handling 2 routes: Main e NotFound. 正如您在AppComponent类中看到的那样,我正在处理2条路由:Main e NotFound。 The strange thing is that if I write an not existing url in the browser (eg localhost:2056/asdad) the NotFound page is displayed correctly. 奇怪的是,如果我在浏览器中写了一个不存在的URL(例如localhost:2056 / asdad),则NotFound页面会正确显示。

My packages: 我的包裹:

   "angular2": "2.0.0-beta.7",
    "systemjs": "0.19.20",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.33.3",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.2",
    "zone.js": "0.5.15",

My tsd: 我的tsd:

{
  "version": "v4",
  "repo": "borisyankov/DefinitelyTyped",
  "ref": "master",
  "path": "typings",
  "bundle": "typings/tsd.d.ts",
  "installed": {
    "jquery/jquery.d.ts": {
      "commit": "9027703c0bd831319dcdf7f3169f7a468537f448"
    },
    "bootstrap/bootstrap.d.ts": {
      "commit": "9027703c0bd831319dcdf7f3169f7a468537f448"
    }
  },
  "ambientDependencies": {
    "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#6697d6f7dadbf5773cb40ecda35a76027e0783b2"
  }
}

My boot: 我的靴子:

///<reference path="../../node_modules/angular2/typings/browser.d.ts"/>

import {bootstrap}    from 'angular2/platform/browser'
import {AppComponent} from './app.component'
import {ROUTER_PROVIDERS} from 'angular2/router';
import {HTTP_PROVIDERS} from 'angular2/http'
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/retry';

bootstrap(AppComponent, [ROUTER_PROVIDERS, HTTP_PROVIDERS]);

My routing class: 我的路由课程:

import {Component} from 'angular2/core';
import {RouteConfig, Router, Location, Instruction, ROUTER_DIRECTIVES} from 'angular2/router';
import {MainComponent} from './components/sections/main.component';
import {NotFoundComponent} from './components/sections/not-found.component';
import {EventEmitterService} from './services/event-emitter.service';
import {NavigationService, Routes} from './services/navigation.service'; 

@Component({
    selector: 'my-app',
    template: '<router-outlet></router-outlet>',
    directives: [ROUTER_DIRECTIVES],
    providers: [EventEmitterService, NavigationService]
})
@RouteConfig([
    {path:'/' , name: Routes.Main , component: MainComponent, useAsDefault: true},
    {path:'/not-found' , name: Routes.NotFound , component: NotFoundComponent}
])
export class AppComponent
{   
    public constructor(private _router: Router, _location:Location) 
    {
        _router.recognize(_location.path()).then((instruction: Instruction) => {
            if (!instruction)
                _router.recognize('/not-found').then((instruction: Instruction) => _router.navigateByInstruction(instruction, true));
        });
    }
}

After a terrible day I found out the problem. 糟糕的一天过后,我发现了问题所在。

Using Angular2. 使用Angular2。 beta6 when you compile the .ts files you get the error below. beta6编译.ts文件时,出现以下错误。

To avoid such error it is suggested to use this line of code in the boot (main) class: 为了避免此类错误,建议在引导(主)类中使用以下代码行:

///<reference path="../../node_modules/angular2/typings/browser.d.ts"/>

This line of code removes the compile error but causes an infinite loop when you open the app (to be precise, the error is present only if a component contains two or more children components) 这行代码消除了编译错误, 但是在您打开应用程序时导致了无限循环(确切地说,仅当一个组件包含两个或多个子组件时才会出现该错误)

This is the above mentioned compiling error (the strange thing is that even if you get this error, the website works great): 这是上面提到的编译错误(奇怪的是,即使您收到此错误,该网站也能正常运行):

node_modules/angular2/src/core/change_detection/parser/locals.d.ts(3,14): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/change_detection/parser/locals.d.ts(4,42): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/debug/debug_node.d.ts(14,13): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/debug/debug_node.d.ts(24,17): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/debug/debug_node.d.ts(25,17): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/di/provider.d.ts(436,103): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/di/provider.d.ts(436,135): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/render/api.d.ts(13,13): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/render/api.d.ts(14,84): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/facade/collection.d.ts(1,25): error TS2304: Cannot find name 'MapConstructor'.
node_modules/angular2/src/facade/collection.d.ts(2,25): error TS2304: Cannot find name 'SetConstructor'.
node_modules/angular2/src/facade/collection.d.ts(4,27): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/facade/collection.d.ts(4,39): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/facade/collection.d.ts(7,9): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/facade/collection.d.ts(8,30): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/facade/collection.d.ts(11,43): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/facade/collection.d.ts(12,27): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/facade/collection.d.ts(14,23): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/facade/collection.d.ts(15,25): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/facade/collection.d.ts(95,41): error TS2304: Cannot find name 'Set'.
node_modules/angular2/src/facade/collection.d.ts(96,22): error TS2304: Cannot find name 'Set'.
node_modules/angular2/src/facade/collection.d.ts(97,25): error TS2304: Cannot find name 'Set'.
node_modules/angular2/src/facade/lang.d.ts(13,17): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/facade/lang.d.ts(14,17): error TS2304: Cannot find name 'Set'.
node_modules/angular2/src/facade/lang.d.ts(78,59): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/facade/promise.d.ts(1,10): error TS2304: Cannot find name 'Promise'.
node_modules/angular2/src/facade/promise.d.ts(3,14): error TS2304: Cannot find name 'Promise'.
node_modules/angular2/src/facade/promise.d.ts(8,32): error TS2304: Cannot find name 'Promise'.
node_modules/angular2/src/facade/promise.d.ts(9,38): error TS2304: Cannot find name 'Promise'.
node_modules/angular2/src/facade/promise.d.ts(10,35): error TS2304: Cannot find name 'Promise'.
node_modules/angular2/src/facade/promise.d.ts(10,93): error TS2304: Cannot find name 'Promise'.
node_modules/angular2/src/facade/promise.d.ts(11,34): error TS2304: Cannot find name 'Promise'.
node_modules/angular2/src/facade/promise.d.ts(12,32): error TS2304: Cannot find name 'Promise'.
node_modules/angular2/src/facade/promise.d.ts(12,149): error TS2304: Cannot find name 'Promise'.
node_modules/angular2/src/facade/promise.d.ts(13,43): error TS2304: Cannot find name 'Promise'.
node_modules/angular2/src/http/headers.d.ts(43,59): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/http/url_search_params.d.ts(11,16): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/platform/browser/browser_adapter.d.ts(75,33): error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/platform/dom/dom_adapter.d.ts(85,42): error TS2304: Cannot find name 'Map'.
node_modules/rxjs/CoreOperators.d.ts(22,67): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/CoreOperators.d.ts(72,67): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/CoreOperators.d.ts(77,31): error TS2304: Cannot find name 'PromiseConstructor'.
node_modules/rxjs/CoreOperators.d.ts(77,54): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/Observable.d.ts(65,67): error TS2304: Cannot find name 'PromiseConstructor'.
node_modules/rxjs/Observable.d.ts(65,88): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/Observable.d.ts(72,84): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/Observable.d.ts(77,38): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/Observable.d.ts(100,66): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/Observable.d.ts(154,66): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/Observable.d.ts(159,31): error TS2304: Cannot find name 'PromiseConstructor'.
node_modules/rxjs/Observable.d.ts(159,54): error TS2304: Cannot find name 'Promise'.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM