Angular $routeParams is blank

后端 未结 7 1035
不知归路
不知归路 2021-02-19 03:49

I have a really simple Angular app that I\'ve distilled to the following:

var napp = angular.module(\'Napp\',[\'ngResource\']);

var CompanyCtrl = function($scop         


        
7条回答
  •  攒了一身酷
    2021-02-19 04:16

    It works for me http://plunker.co/edit/ziLG1cZg8D8cYoiDcWRg?p=preview

    But you have some errors in your code:

    • Your don't seem to have a ngView in your code. The $routeProvider uses the ngView to know where it should insert the template's content. So you need it somewhere in your page.

    • You're specifying your CompanyCtrl in two places. You should specify it either in the $routeProvider, or in you template using ng-controller. I like specifying it in the template, but that's just personal preference.

    • Although not an error, you're specifying your CompanyCtrl in the global scope, instead of registering it on your Napp module using Napp.controller(name, fn).

    Hope this helps!
    You can always go on #angularjs irc channel on freenode: there's always active people ready to help

提交回复
热议问题