TechQA.

The controller with the name 'viewctrl' is not registered

234 views Asked by amol pawar At 2019-08-08T06:03:39+00:00 08 August 2019 at 06:03 2025-12-10T01:45:00+00:00

Error Image

<div class="wrapper" id="body" ng-app="masterview" ng-controller="masterctrl" data-ng-init="getmenus()">
    <header id="header">
        <div class="header-width row">
            <div class="col-xl-9">
                <div class="logo float-xs-left">
                    <a href="#">
                        <img src="~/img/logo_accord.png" alt="Ace Report" />
                    </a>
                </div>
            </div>
            <div class="col-xl-3 header-right">
                <div class="header-inner-right">
                    <div class="float-default chat">
                        <div class="right-icon">
                            <a href="#">
                                <i class="fa fa-envelope-o"></i>
                            </a>
                        </div>
                    </div>
                    <div class="float-default chat">
                        <div class="right-icon">
                            <a href="#">
                                <i class="fa fa-comments-o"></i>
                            </a>
                        </div>
                    </div>
                    <div class="user-dropdown">
                        <div class="btn-group">
                            <a href="index.html#" class="user-header dropdown-toggle" data-toggle="dropdown"
                                   data-animation="slideOutUp" aria-haspopup="true"
                                   aria-expanded="false">
                                <img src="~/assets/images/user.jpg" alt="Profile image" />
                            </a>
                            <div class="dropdown-menu user drop-profile dropdown-card dropdown-card-profile animated flipInY">
                                    @*
                                <header class="card-header d-flex">
                                    <a href="javascript:void(0);" class="text-center">
                                        <i class="fa fa-user"></i>
                                    </a>
                                    <a href="javascript:void(0);" class="text-center">
                                        <i class="fa fa-cog"></i>
                                    </a>
                                    <a href="javascript:void(0);" class="text-center">
                                        <i class="fa fa-power-off"></i>
                                    </a>
                                </header>*@

                                <ul class="list-unstyled card-body">
                                        @*
                                    <li>
                                        <a href="index.html#">
                                            <span>
                                                <span class="align-middle">Manage Accounts</span>
                                            </span>
                                        </a>
                                    </li>*@

                                    <li>
                                        <a href="index.html#">
                                            <span>
                                                <span class="align-middle">Change Password</span>
                                            </span>
                                        </a>
                                    </li>
                                        @*
                                    <li>
                                        <a href="index.html#">
                                            <span>
                                                <span class="align-middle">Check Inbox</span>
                                            </span>
                                        </a>
                                    </li>*@

                                    <li>
                                        <a href="@Url.Action("Logout", "Admin")">
                                            <span>
                                                <span class="align-middle">Sign Out</span>
                                            </span>
                                        </a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--top menu bar-->
        <div id="header-icon" class="" >
            <div class="header-width">
                <div class="col-xl-12">
                    <div class="menucontainer">
                        <div class="overlapblackbg"></div>
                        <a id="navtoggle" class="animated-arrow">
                            <span></span>
                        </a>
                        <nav id="nav" class="topmenu" role="navigation">
                            <div class="sidebar-search">
                                <div class="logo float-xs-left">
                                    <a href="#"></a>
                                </div>
                                <a href="javascript:void(0)">
                                    <i class="search-close icon_search"></i>
                                </a>
                            </div>
                            <!--left menu-->
                            <ul id="dvMenuInner" class="nav navbar-nav">
                                <li ng-repeat="parent in menu" class="dropdown">
                                    <a href="/{{parent.url}}/{{parent.actionname}}" ng-show="!parent.children">
                                        <span class="fa fa-tachometer header-icon" aria-hidden="true"></span>{{parent.menuname}}

                                    </a>
                                    <a href="/{{parent.url}}/{{parent.actionname}}" ng-show="parent.children" class="dropdown-toggle" data-toggle="dropdown">
                                        <span class="fa fa-tachometer header-icon" aria-hidden="true"></span>{{parent.menuname}}

                                    </a>
                                    <ul class="dropdown-menu" ng-show="parent.children">
                                        <li ng-repeat="child in parent.children" ng-show="!child.childrencc">
                                            <a href="/{{child.url}}/{{child.actionname}}">{{child.menuname}}</a>
                                        </li>
                                        <li class="dropdown-submenu" ng-repeat="child in parent.children" ng-show="child.childrencc">
                                            <a href="/{{child.url}}/{{child.actionname}}" ng-if="child.url && child.actionname">{{child.menuname}}</a>
                                            <a href="#" ng-if="!child.url || !child.actionname">{{child.menuname}}</a>
                                            <ul class="dropdown-menu" ng-show="child.childrencc">
                                                <li ng-repeat="children in child.childrencc">
                                                    <a href="/{{children.url}}/{{children.actionname}}">{{children.menuname}}</a>
                                                </li>
                                            </ul>
                                        </li>
                                    </ul>
                                </li>
                            </ul>
                        </nav>
                    </div>
                </div>
            </div>
        </div>
    </header>
    <!-- END HEADER -->
    <!-- START CONTENT -->
    <section id="main" class="container-fluid">
        <!-- START RIGHT CONTENT -->
            @*
        <div class="row">
            <!-- START RIGHT CONTENT -->
            <section id="content-wrapper" class="form-elements">
                <!-- START PAGE TITLE -->
                <div class="site-content-title">
                    <h2 class="float-xs-left content-title-main">Client Dashboard</h2>
                    <!-- START BREADCRUMB -->
                    <ol class="breadcrumb float-xs-right">
                        <li class="breadcrumb-item">
                            <span class="fa fa-home" aria-hidden="true"></span>
                            <a href="index.html#">Home</a>
                        </li>
                        <li class="breadcrumb-item active">Dashboard</li>
                    </ol>
                    <!-- END BREADCRUMB -->
                </div>
                <!-- END PAGE TITLE -->
            </section>
        </div>*@
            @*
        <div class="contain-inner"></div>*@


        <ng-view> @RenderBody()</ng-view>
    </section>
        @*


</div>

I want menus to be loaded at the start of the application and I have multiple pages in MVC, so the problem is getting the error stated that controller not registered. so can you tell me how can I handle ng-app and ng-controller in master page and pages?

I am loading menus as follows:

 app.controller('masterctrl', function ($scope, $http, $window) {
   $scope.getmenus = function () {
    var holding_url = encodeURI(APIURL + "getmenus");
    $http.get(holding_url)
        .then(function (response) {
            $scope.names = response.data.t1;
            $scope.menu = [];
            $scope.childrenmenu = [];
            $scope.count = 0;
            angular.forEach(response.data.t1, function (value, key) {
                if (value.parentid == 0) {
                    $scope.menu.push(value);
                }
            });

            angular.forEach(response.data.t1, function (value, key) {
                if (value.parentid != 0) {
                    angular.forEach($scope.menu, function (value2, key2) {
                        if (value.parentid == value2.menuid) {
                            if (value2.children == undefined) {
                                value2.children = [];
                                value2.showChildren = false;
                            }
                            value2.children.push(value);
                            $scope.childrenmenu.push(value);
                        }
                    });
                }
            });        

            angular.forEach(response.data.t1, function (value, key) {
                if (value.parentid != 0) {
                    angular.forEach($scope.childrenmenu, function (value3, key3) {
                        if (value.parentid == value3.menuid) {
                            if (value3.childrencc == undefined) {
                                value3.childrencc = [];
                                value3.showChildren = false;
                            }
                            value3.childrencc.push(value);
                        }
                    });
                }
            });

Please see image due to that error data in table is also not loading properly, because master page and pages controller can not work together.

angularjs ng-view ng-controller ng-app
Original Q&A
2

There are 2 answers

1
vinayak vinayak On 2019-08-08T10:03:09+00:00 08 August 2019 at 10:03 BEST ANSWER

you need to bootstrap them using angular.bootstrap()

first give id to the child div lets say App2

<div class="ibox float-e-margins" ng-app="childview" id="App2">
</div>
 angular.bootstrap(document.getElementById("App2"), ['childview']);

this will allow Angular to run subsequent views to run on the dom

1
adnan kaya adnan kaya On 2019-08-08T07:27:52+00:00 08 August 2019 at 07:27

Why not this ?

<div class="wrapper" id="body" ng-app="masterview" >
 <div ng-controller="masterctrl" data-ng-init="getmenus()">

  <!-- rest of your code --->
 </div>
</div>

Related Questions in ANGULARJS

  • How to automatically change path in angular when scrolling
  • Error two clicks to be able to login Angular 16
  • Passing an array of objects through the $http.post method in angular JS does not work
  • Understanding how to apply Angular Signals from beginning on an existing service
  • provider duplicate while compiling a Cordova application for the Android platform
  • How can I use angularjs $parse service in Angular?
  • Width of custom headers in ag-grid (angular) doesn't match with column's width
  • Issues with Katex/ngx-markdown Rendering in Angular 16
  • How to make Angular SSR wait for async operations to finish that are initiated in ngOnInit?
  • I want to install @angular/google-maps npm Package in angular 16.2.12 but "npm install @angular/google-maps" this is not working/ tell me other query
  • Angular 17 standalone application integrate CKEditor 5 -- Error: window is not defined
  • Why is $scope >= 0 showing true in interpolation while empty in controller?
  • The XMLHttpRequest compatibility library was not found
  • Making Gantt Chart Column Labels More Readable
  • Pass key-value pairs of object as individual arguments to component in Angular

Related Questions in NG-VIEW

  • Selenium unable to interact with any element on a "ng-view" screen
  • Ng-View is not displaying data
  • Can't load a partial view from a file in Angularjs
  • ng-model is not working inside ng-view with global controller
  • Angular 1.8 ng-view not loading html pages and no errors
  • How to get the last table from this site?
  • The controller with name is not registered when loading the html through template
  • The controller with the name 'viewctrl' is not registered
  • My ng-view" directive doesn't function the way it is supposed to
  • AngularJS loads only the component html instead of entire ng-view
  • How to solve the problem of passing ID as name of file to be loaded as ID.html?
  • in angularjs trying to loop factory data to create config also ng-view not showing html?
  • Loading ng-view html templates
  • ngRoute don't display view with in ngView
  • Route Provider do not redirect

Related Questions in NG-CONTROLLER

  • How does ng-controller locate the right controller file?
  • Expression not working in the view that is set by a service in AngularJS
  • ng-controller with ng-include doesn't bind correctly
  • Angular ng-model and controller won't work
  • Publishing an Input outside the Form to the Form via name programmatically with Angularjs
  • The controller with the name 'viewctrl' is not registered
  • AngularJS : Problem while using ng-controller
  • ng-controller with same name in different ng-app not working
  • Message won't display a second time after being closed
  • Connecting to multiple REST services using angularjs controllers not linking
  • Return list of properties using ng-repeat (AngularJS)
  • AngularJS two http get in one controller make problems
  • ng-options disabled in array
  • Routes: controller doesn't get called
  • Get undefined when reading $scope variable

Related Questions in NG-APP

  • How can I add weeks to current date and return a result in the form field?
  • How to add values from an Object Attributes and display them in AngularJS
  • Modifying body tag in Oracle
  • The controller with the name 'viewctrl' is not registered
  • How to use multiple ng-app and add new modal
  • resolve the following error Uncaught Error: [$injector:modulerr]
  • Angular project, ng-app directive only found in vendor.bundle.js.map
  • sending data to another app modul (another page) using a dblclick function in angularjs
  • Why AngularJs 2 supports bootstrapping only through code
  • I want to use two angularjs modules/app in the same web page
  • Second app is not working in angular js
  • AngularJS - object values not show in {{}}
  • Updation of a shared object that is created inside factory method of a module is not updating in another module in Angular JS
  • How to use ng-app and ng-controller for many pages?
  • If the value of ng-app is not empty string the angular directives are not working

Popular Questions

  • How do I undo the most recent local commits in Git?
  • How can I remove a specific item from an array in JavaScript?
  • How do I delete a Git branch locally and remotely?
  • Find all files containing a specific text (string) on Linux?
  • How do I revert a Git repository to a previous commit?
  • How do I create an HTML button that acts like a link?
  • How do I check out a remote Git branch?
  • How do I force "git pull" to overwrite local files?
  • How do I list all files of a directory?
  • How to check whether a string contains a substring in JavaScript?
  • How do I redirect to another webpage?
  • How can I iterate over rows in a Pandas DataFrame?
  • How do I convert a String to an int in Java?
  • Does Python have a string 'contains' substring method?
  • How do I check if a string contains a specific word?

Popular Tags

javascript python java c# php android html jquery c++ css ios sql mysql r reactjs node.js arrays c asp.net json

Trending Questions

  • UIImageView Frame Doesn't Reflect Constraints
  • Is it possible to use adb commands to click on a view by finding its ID?
  • How to create a new web character symbol recognizable by html/javascript?
  • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
  • Heap Gives Page Fault
  • Connect ffmpeg to Visual Studio 2008
  • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
  • How to avoid default initialization of objects in std::vector?
  • second argument of the command line arguments in a format other than char** argv or char* argv[]
  • How to improve efficiency of algorithm which generates next lexicographic permutation?
  • Navigating to the another actvity app getting crash in android
  • How to read the particular message format in android and store in sqlite database?
  • Resetting inventory status after order is cancelled
  • Efficiently compute powers of X in SSE/AVX
  • Insert into an external database using ajax and php : POST 500 (Internal Server Error)
  • Privacy
  • Terms
  • Cookies
  • Homegardensmart
  • Math
  • Aftereffectstemplates