Multiple controllers with AngularJS in single page app

前端 未结 7 740
不思量自难忘°
不思量自难忘° 2020-12-22 16:44

I want to know is how to use multiple controllers for a single page application. I have tried to figure it out and I\'ve found questions very similar to mine, but there is j

7条回答
  •  旧巷少年郎
    2020-12-22 17:07

    What is the problem? To use multiple controllers, just use multiple ngController directives:

    Stuff here

    You will need to have the controllers available in your application module, as usual.

    The most basic way to do it could be as simple as declaring the controller functions like this:

    function widgetController($scope) {
       // stuff here
    }
    
    function menuController($scope) {
       // stuff here
    }
    

提交回复
热议问题