Angularjs controller showing undefined?

I am working on a node application using angularjs and cassandra. when I go to a page such as the registration page, then the front part goes accordingly, but it shows an error that the controller is undefined. Error: Error: areq Bad argument

this is the app.js file (main js configuration file)

angular.module('app', ['ui.router'])
.config(['$urlRouterProvider', '$stateProvider',
    function($urlRouterProvider, $stateProvider) {
        $urlRouterProvider.otherwise('/');
        $stateProvider
            .state('home', {
                url: '/',
                templateUrl: '/browser/views/home.html'
            })
            .state('register', {
                url: '/register',
                templateUrl: '/browser/views/register.html',
                controller: 'RegisterCtrl'
            })
            .state('login', {
                url: '/login',
                templateUrl: '/browser/views/login.html',
                controller: 'LoginCtrl'
            })
    }
]);

This is the register.html file, followed by the controller path.

<div ng-controller="RegisterCtrl" class="container-fluid">
<div class="row custom-row2">
    <div class="col-md-6 col-lg-6 col-sm-6">
        <h4 class="sign_up">{{ title }}</h4>
        <form class="form-horizontal" id="login_form" name="login_form" role="form">
            <div class="form-group">
                <label class="control-label col-sm-3" for="name">Name:</label>
                <div class="col-sm-9">
                    <input ng-model="name" type="text" class="form-control" name="field1" id="name" aria-describedby="inputSuccess3Status" placeholder="Enter Your Name....">
                </div>
            </div>
        </form>
    </div>
</div>

This is the registerCtrl.js file that comes to check in firebug

 angular.module('app', ['ui.router'])
    .controller('RegisterCtrl', ['$scope',
        function($scope, RegiserService) {
            $scope.title = "Sign Up";
        }
    ]);

but the title , which should come from the registerCtrl controller, does not fit and {{title}} fits in that place.

I went through several times through this, but could not understand what was going wrong when defining the controller.

+4
2

, angular.module('app', ['ui.router']).controller. getter angular.module('app'), . , RegiserService, , app. angular.module('moduleName', [..dep]) getter angular.module('app') .

( ):

angular.module(moduleName, [requires], [configFn]);

Getter ( ):

angular.module(moduleName);

.

. , (, ).

, : -

 angular.module('app').controller('RegisterCtrl',...
 angular.module('app').service('RegiserService',...
+3

, PSL, - RegiserService? , .

angular.module('app', ['ui.router'])
    .controller('RegisterCtrl', ['$scope', 'RegiserService',
        function($scope, RegiserService) {
            $scope.title = "Sign Up";
        }
    ]);
+1

Source: https://habr.com/ru/post/1570005/


All Articles