Angularjs2 zone.js?rev=@@hash:390 Error: Uncaught (in promise): Error: (SystemJS) Invalid or unexpected token

angularjs2 Template reference variables ( #var )

在使用Template reference variables ( #var )的时候,命名不能和components定义的属性一致,不然会报如下错误。

zone.js?rev=@@hash:390 Error: Uncaught (in promise): Error: (SystemJS) Invalid or unexpected token
    SyntaxError: Invalid or unexpected token
        at eval ()
        at Object.eval (https://127.0.0.1:3000/app.module.js:25:18)
        at eval (https://127.0.0.1:3000/app.module.js:73:4)
        at eval (https://127.0.0.1:3000/app.module.js:74:3)
    Evaluating https://127.0.0.1:3000/home/home-cmp.js
    Evaluating https://127.0.0.1:3000/app.module.js
    Evaluating https://127.0.0.1:3000/index.js
    Error loading https://127.0.0.1:3000/index.js
(SystemJS) Invalid or unexpected token
    SyntaxError: Invalid or unexpected token
        at eval ()
        at Object.eval (https://127.0.0.1:3000/app.module.js:25:18)
        at eval (https://127.0.0.1:3000/app.module.js:73:4)
        at eval (https://127.0.0.1:3000/app.module.js:74:3)
    Evaluating https://127.0.0.1:3000/home/home-cmp.js
    Evaluating https://127.0.0.1:3000/app.module.js
    Evaluating https://127.0.0.1:3000/index.js
    Error loading https://127.0.0.1:3000/index.js
        at eval ()
        at Object.eval (https://127.0.0.1:3000/app.module.js:25:18)
        at eval (https://127.0.0.1:3000/app.module.js:73:4)
        at eval (https://127.0.0.1:3000/app.module.js:74:3)
    Evaluating https://127.0.0.1:3000/home/home-cmp.js
    Evaluating https://127.0.0.1:3000/app.module.js
    Evaluating https://127.0.0.1:3000/index.js
    Error loading https://127.0.0.1:3000/index.js
(SystemJS) Invalid or unexpected token
    SyntaxError: Invalid or unexpected token
        at eval ()
        at Object.eval (https://127.0.0.1:3000/app.module.js:25:18)
        at eval (https://127.0.0.1:3000/app.module.js:73:4)
        at eval (https://127.0.0.1:3000/app.module.js:74:3)
    Evaluating https://127.0.0.1:3000/home/home-cmp.js
    Evaluating https://127.0.0.1:3000/app.module.js
    Evaluating https://127.0.0.1:3000/index.js
    Error loading https://127.0.0.1:3000/index.js
    at resolvePromise (https://127.0.0.1:3000/zone.js/dist/zone.js?rev=@@hash:468:31)
    at resolvePromise (https://127.0.0.1:3000/zone.js/dist/zone.js?rev=@@hash:453:17)
    at https://127.0.0.1:3000/zone.js/dist/zone.js?rev=@@hash:502:17
    at ZoneDelegate.invokeTask (https://127.0.0.1:3000/zone.js/dist/zone.js?rev=@@hash:265:35)
    at Zone.runTask (https://127.0.0.1:3000/zone.js/dist/zone.js?rev=@@hash:154:47)
    at drainMicroTaskQueue (https://127.0.0.1:3000/zone.js/dist/zone.js?rev=@@hash:401:35)
    at XMLHttpRequest.ZoneTask.invoke (https://127.0.0.1:3000/zone.js/dist/zone.js?rev=@@hash:339:25)

源码如下:

```



```javascript
export class LoginCmp implements OnInit {
  username: string;
  ...
}

#username 和 username: string 命名一致了。改为不同命名即可。

你可能感兴趣的:(Angularjs2 zone.js?rev=@@hash:390 Error: Uncaught (in promise): Error: (SystemJS) Invalid or unexpected token)