Multiple controllers with AngularJS in single page app

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

    <div ng-app="app">
    

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

    <div ng-controller="EditableRowCtrl">
    

    This worked fine

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