I need to create an Angular2 + TypeScript frontend for php + mysql project. When I'm using npm (jspm, tsd, webpack or gulp) or with the link to code.angularjs.org everything works fine. But when I'm trying to use some Angular2 local files only, then systemjs will broke everything by it's components registration and throw to me an exception like this:
Uncaught SyntaxError: Unexpected token <
There are also some confusion in the docs how to implement index.html with scripts and components/views. In the deep of the docs I found one example which almost works for me:
<!DOCTYPE html>
<html>
<head>
<title>angular2 playground</title>
<link rel="stylesheet" href="style.css">
<script src="tools/traceur-runtime.js"></script>
<script src="tools/system.js"></script>
<script src="tools/typescript.js"></script>
<script src="config.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.6/angular2.min.js"></script>
<script>
System.import('app')
.catch(console.error.bind(console));
</script>
</head>
<body>
<my-app>
loading...
</my-app>
</body>
</html>
But when I'm replacing to angular2.min.js to local version I'm getting the error above.
Do anyone knows how to fix it?
Update
Thanks to Chako answer and I did setup in this way and it is working for me:
<script type="text/javascript" src="./libs/es6-shim.min.js"></script>
<script type="text/javascript" src="./libs/system-polyfills.js"></script>
<script type="text/javascript" src="./libs/system.src.js"></script>
<script type="text/javascript" src="./libs/Rx.min.js"></script>
<script type="text/javascript" src="./libs/angular/angular2-polyfills.js"></script>
<script type="text/javascript" src="./libs/angular/angular2.dev.js"></script>
<script type="text/javascript" src="./libs/angular/router.dev.js"></script>
<script type="text/javascript" src="./libs/angular/http.dev.js"></script>
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/main').then(null, console.error.bind(console));
</script>
Also I tried to update to beta 8 and it is broken to find files so I left beta 6 as the stable version.
And some moments:
*.min.jsversions doesn't work properly.- new
Rx.min.jsfrombeta 8was thrown to me an Exception about DI (dependency injection). tscdoesn't supporting by Microsoft any more and it was thrown compile errors and exit fromwatch. So I installedntscwhich works faster but writes more TypeScript errors in console.