How to define controllers in multiple files - AngularJs

前端 未结 4 1200
深忆病人
深忆病人 2021-02-03 23:37

I am trying to define controllers in separate files, but I\'m getting the error:

transactionsController not a function got undefined

4条回答
  •  野的像风
    2021-02-03 23:46

    You Can put this controller in seprate file like mycontroller1.js

        
    
        app.controller('myController', ['$scope',function($scope)    
            {
            $scope.myValue='hello World'
            }])
    
    
    

    Same like this you can create new js file 'myNewcontroller.js' and can put new controller :

    
    
        app.controller('myController2', ['$scope',function($scope)    
            {
            $scope.myValue='hello World'
            }])
    
    
    

    Hope this will help you :) Cheers !!

提交回复
热议问题