简体   繁体   中英

How to set Routing in AngularJS to work properly

I have a problem with Routing in AngularJS. I use version 1.6.x and the latest version of angular.route.min.js file.

When I click the button which should take me to the other view, nothing happens. When searching for answer I found out that Routing in AngularJS doesn't work without node.js server. So I installed it and tried to run my application.

Here came the problem; I don't know how to launch this application on node.js. In CMD on Windows I typed : "node index.html" and I got error. The same is with "node app.js" - my javascript source code file.

I attached screenshots to my source code. If anyone could help me it would be great :-).

Thanks in advance.

My app.js source code.

My groceryList html file where I have a button to addItem.html view file.

Raj's comment seems right on. You don't have a good screenshot of all of your code, but I think that you are missing the <div ng-view></div> aspect from your main view.

I made a plunker example out of your code to demonstrate: https://plnkr.co/edit/kB6ETz?p=preview

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM