2016-02-21 28 views
1

我使用同β7得到一個無限循環,這是Firefox的堆棧跟蹤:Angular2公測7無限循環

Error: Script terminated by timeout at: 
DebugDomRenderer</[email protected]: //localhost:2067/node_modules/angular2/bundles/angular2.dev.js:7184:11 
[email protected]_t:256:18 
[email protected]_t:266:1 
[email protected]_t:266:1 
[email protected]_t:266:1 
[email protected]_t:266:1 
[email protected]_t:266:1 
... 

跳同β7一切正常之前,但如果我現在切換到beta6,我得到相同錯誤。所以我認爲這個問題甚至在以前就存在了。 正如你可以在AppComponent類中看到的,我正在處理2條路由:Main e NotFound。奇怪的是,如果我在瀏覽器中寫入不存在的URL(例如localhost:2056/asdad),NotFound頁面將正確顯示。

我的包:

"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", 

我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" 
    } 
} 

我的靴子:

///<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]); 

我的路由類:

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)); 
     }); 
    } 
} 
+0

回到beta0一切正常。 我想了解發生了什麼問題。我不認爲我是唯一有這個問題的人。我的代碼嚴格遵循教程的代碼 – user3471528

回答

0

經過了可怕的一天,我發現了這個問題。

使用Angular2。 beta6當你編譯.ts文件時,你會得到下面的錯誤。

爲了避免這樣的錯誤,建議使用此行代碼在啓動(主)類:

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

這行代碼刪除編譯錯誤導致當你打開一個無限循環應用程序(準確地說,只有當組件包含兩個或更多子組件時纔會出現錯誤)

這是上面提到的編譯錯誤(奇怪的是,即使您遇到此錯誤, ):

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'.