Using AngularJS Controllers created with angular.module().controller()

后端 未结 2 1439
时光说笑
时光说笑 2020-12-08 02:18

I am still very new to AngularJS and am working through setting up my first application. I would like to be able to do the following:

angular.module(\'App.c         


        
相关标签:
2条回答
  • 2020-12-08 02:45

    Try using a string identifier.

    routeProvider.when('/', {templateUrl: 'partials/home.html', controller: 'home'});

    When you use a literal, it is looking for a variable called home, but that doesn't exist in this case.

    0 讨论(0)
  • 2020-12-08 02:47

    If you are getting controller is not defined error you have to write your controller name within the quotes.

    or define your controller like this

    function controllerName()
    {
       //your code here
    }
    

    refer this: Uncaught ReferenceError:Controller is not defined in AngularJS

    0 讨论(0)
提交回复
热议问题