0

I am using node and angularjs. I have a frame like page inside an ejs that is passed content to load into the includes dynamically.

<div ng-app="thisApp">
  <div ng-controller='MainCtrl'>
     {{ firstMessage }}
     <div id='contentFromNode' ng-include='<%= pageContent %>'></div>
  </div>
</div>
<script>
    var thisApp = angular.module('thisApp', []);
    thisApp.controller('MainCtrl', [ '$scope', function($scope) {
         $scope.firstMessage = "Main Controller Working Fine";
    }])
</script>

and then the passed content might be just an html page containing something like this:

<div ng-controller='NestedCtrl' id='content-type-container'>
    {{ nestedMessage }}
</div>
<script>
     thisApp.controller('NestedCtrl', [function(){
         var nested = this;
         nested.nestedMessage = "Nested Won't Work";
     }])
</script>

So I have tried $scope within the NestCtrl instead of referencing this, I have tried moving the script tag above and below (ideally this get separated eventually anyway). I have tried aliasing the controllers, however my problem is the in registration of the controller itself as I get that great Error: [$controller:ctrlreg] error. The page is loading the content fine? Any ideas what I am doing wrong here?

Justin
  • 4,461
  • 22
  • 87
  • 152

1 Answers1

0

Seems JQlite doesn't support this. You have to include jquery or lazy load the script. Refer

AngularJS: How to make angular load script inside ng-include?

Hari Prathap
  • 102
  • 7