Multiple controllers with AngularJS in single page app

前端 未结 7 749
不思量自难忘°
不思量自难忘° 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:32

    I just put one simple declaration of the app

    var app = angular.module("app", ["xeditable"]);
    

    Then I built one service and two controllers

    For each controller I had a line in the JS

    app.controller('EditableRowCtrl', function ($scope, CRUD_OperService) {
    

    And in the HTML I declared the app scope in a surrounding div

    and each controller scope separately in their own surrounding div (within the app div)

    This worked fine

提交回复
热议问题