2016-04-02 55 views
0

我知道這個問題被問了100次,但我得到這個錯誤。請檢查截圖。Angular 2錯誤:SyntaxError:意外的令牌<

Error: SyntaxError: Unexpected token < at Object.eval (http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/date-formatter.js:2:14) at eval (http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/date-formatter.js:13:4) Evaluating http://localhost:3000/moment Evaluating http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/date-formatter.js Evaluating http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/datepicker-inner.js Evaluating http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/datepicker.js Evaluating http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker/datepicker-popup.js Evaluating http://localhost:3000/node_modules/ng2-bootstrap/components/datepicker.js Evaluating http://localhost:3000/node_modules/ng2-bootstrap/ng2-bootstrap.js Error loading http://localhost:3000/app/main.js

我跟着這是考慮了固定系統配置

System.config({ 
     packages: { 
      app: { 
      format: 'register', 
      defaultExtension: 'js' 
      }, 
      'ng2-bootstrap': { 
      defaultExtension: 'js' 
      } 
     }, 
     map: { 
      // place for ng2 modules mapping 
      'ng2-bootstrap': 'node_modules/ng2-bootstrap' 
     } 
}); 

,但這個解決方案後,我得到的錯誤和頁面沒有加載的解決方案......

人知道請遵循的步驟請讓我知道。

+2

'我知道這個問題被問到100次左右.... ... –

+0

請發佈您的代碼爲datepickerformatter – KnowHoper

回答

0

事實上,ng2-boostrap提供了一個捆綁文件。簡單地把它添加到一個腳本元素,並刪除SystemJS的相關配置:

<script src="node_modules/ng2-bootstrap/bundles/ng2-bootstrap.js"></script> 

System.config({ 
    packages: { 
     app: { 
     format: 'register', 
     defaultExtension: 'js' 
     }, 
     'ng2-bootstrap': { 
     defaultExtension: 'js' 
     } 
    }, 
    map: { 
     // place for ng2 modules mapping 
     'ng2-bootstrap': 'node_modules/ng2-bootstrap' 
    } 
}); 

這可以安裝NG2的自舉與NPM之後進行。

相關問題