0

main.html

<script src="main.js">
     var app = angular.module('myApp', []);
</script>
<div ng-include="'login.html'"></div>

login.html

    <script src="Components/LoginModule/LoginCtrl.js"></script>
    <div ng-controller="LoginCtrl">
        <form-field ng-field-data="{{login.usr_name}}"></form-field>
        <form-field ng-field-data="{{login.password}}"></form-field>
    </div>

i defined LoginCtrl controller in LoginCtrl.js, and want it to be loaded alongwith ng-include.

But i am facing following error

[$controller:ctrlreg] The controller with the name 'LoginCtrl' is not registered.

where as if i define my controller in main.html, it work perfectly fine

2
  • 2
    This is lazy loading. It's not officially supported by the framework. Use third-party solutions like ozLazyLoad. Commented Feb 16, 2018 at 7:19
  • i kind of solved it by using $(selector).load(url) instead of using nginclude. and bootstraping the loaded div manually Commented Mar 14, 2018 at 7:01

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.