I've been trying to do the quick start guide for Angular2. I did the example as instructed in the quick guide. However, when I ran it, it displayed the following message 'Cannot Get'. Does anyone know why this is happening?
boot.js file
// JavaScript source code (function (app) { document.addEventListener('DOMContentLoaded', function () { ng.platform.browser.bootstrap(app.AppComponent); }); })(window.app || (window.app = {}));
The app.component.js file
(function (app) { app.AppComponent = ng.core.Component({ Selector: 'my-app', template: '<h1>My First Angular 2 App </h1>' }) .class({ constructor: function () { } }); })(window.app || window.app == {});
The index file
<html> <head> <title>Angular 2 QuickStart</title> <!-- 1. Load libraries --> <script src="https://code.angularjs.org/2.0.0-beta.0/angular2-polyfills.js"></script> <script src="https://code.angularjs.org/2.0.0-beta.0/Rx.umd.js"></script> <script src="https://code.angularjs.org/2.0.0-beta.0/angular2-all.umd.dev.js"></script> <!-- 2. Load our 'modules' --> <script src='app/app.component.js'></script> <script src='app/boot.js'></script> </head> <!-- 3. Display the application --> <body> <my-app>Loading...</my-app> </body> </html>
Finally, the package.json file
{ "name": "angular2-quickstart", "version": "1.0.0", "scripts": { "start": "npm run lite", "lite": "lite-server" }, "license": "ISC", "dependencies": { "angular2": "2.0.0-beta.0", "systemjs": "0.19.6", "es6-promise": "^3.0.2", "es6-shim": "^0.33.3", "reflect-metadata": "0.1.2", "rxjs": "5.0.0-beta.0", "zone.js": "0.5.10" }, "devDependencies": { "lite-server": "^1.3.1" } }
I ran the line 'npm start' which opened the browser and displayed 'Cannot Get'
I got this error when index.html was not in the correct folder.
If that is the case, putting it in the main angular project's root folder should resolve the error.
I have had the same problem: Cannot GET / pagename
on every page. I searched the internet but did not found a solution like this one.
My project resided inside a folder with ASCII spaces since the repository name also contained spaces.
The folder in which your project resides, should not contain any space or ASCII Character "%20".
After this change my project did not give the Cannot GET / pagename
error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With