美文网首页
Angularjs2 zone.js?rev=@@hash:39

Angularjs2 zone.js?rev=@@hash:39

作者: 胡萝卜1987 | 来源:发表于2017-03-19 23:21 被阅读0次

    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 (<anonymous>)
            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 (<anonymous>)
            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 (<anonymous>)
            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 (<anonymous>)
            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)
    

    源码如下:

    <input type="text" class="form-control"
                 placeholder="Email address"
                 name="username" id="username"
                 required autofocus
                 [(ngModel)]="username" #username="ngModel">```
    
    
    
    ```javascript
    export class LoginCmp implements OnInit {
      username: string;
      ...
    }
    

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

    相关文章

      网友评论

          本文标题:Angularjs2 zone.js?rev=@@hash:39

          本文链接:https://www.haomeiwen.com/subject/kfovnttx.html