angularjs multiple controllers on one page

后端 未结 5 947
甜味超标
甜味超标 2021-02-12 15:50

I have a page with multiple controllers, one of the controller is being used in 2 different divs within the same page. I am not sure if it is a scope issue or I just miss someth

5条回答
  •  日久生厌
    2021-02-12 16:34

    You need to make some changes in controller and view.

    var app = angular.module('plunker', []);
    
     app.controller('subCCtrl', function($scope) {
       $scope.hideThisBox = false;
       $scope.update = function(label) {
    
         if (label == 'Cost')
           $scope.displaybox = true;
         else
           $scope.displaybox = false;
       }
     });
     app.controller('subACtrl', function($scope) {
    
     });
    
     app.controller('subBCtrl', function($scope) {
    
     });
    

    HTML :

    
    
    
      
        
        AngularJS Plunker
        
        
          
      
      
        
        
      
    
      
                

    Do stuff that uses subACtrl
    Do stuff that uses subBCtrl

提交回复
热议问题