2

I'm already using the Angular Bootstrap Calendar and it's working fine. I've added a button to show a modal so I can add a new event using the ui.bootstrap.datepicker.

When the modal pops up, I get the following console message:

"Error: [ng:areq] http://errors.angularjs.org/1.4.3/ng/areq?p0=DatepickerDemoCtrl&p1=not%20a            1.#QNAN0unction%2C%20got%20undefined

Here's a sample of the code I have in my plunker (index.html)

<body ng-cloak="" ng-app="demo">
    <div id="demo" ng-controller="MainCtrl as vm" class="row">

    <button class="btn btn-primary pull-right" ng-click="vm.eventCreateClicked(vm.events)">Add new event</button>

    <mwl-calendar> </mwl-calendar>    --> Calendar defined in here      


    <div ng-app="app" ng-controller="DatepickerDemoCtrl">
    <script type="text/ng-template" id="modalCreateEventContent.html">
      <div class="modal-body" id="modalEventCreate">
      </div>
    </script>
    </div> <!-- ng-controller -->

</div>        
</body>

My Add new event button calls the eventCreateClicked function in demo.js

1
  • two ng-app wouldn't work on the same page.. Commented Nov 2, 2015 at 20:46

2 Answers 2

1

Nested apps are doable in Angular but aren't available out of the box and can't be generally recommended. This case isn't an exception. Nested ng-app won't do any harm here either, it just will be ignored.

DatepickerDemoCtrl belongs to ui.bootstrap.demo module (not app), therefore ui.bootstrap.demo module should be loaded in demo module:

angular
  .module('demo', ['mwl.calendar', 'ui.bootstrap', 'ngTouch', 'ngAnimate', 'ui.bootstrap.demo'])
Sign up to request clarification or add additional context in comments.

5 Comments

Super, this got rid of the error above. Thanks a lot! I get a Error: v is undefined related to /0.13.1/ui-bootstrap-tpls.min.js and AngularJS, but i'm guessing that's another problem.
Always use unminified versions of libraries during development, this way the errors make more sense.
The fix above got rid of the erreor I had, but it seems like it ignores datetimepicker.js when the modal pops up, so I get other errors about the datetimepicker. see my plunker
It is the same plunker as in original post, nothing was fixed there. It is large piece of code, I would suggest to resolve the issues one by one in separate questions.
Done - link here
0

You have nested ng-app. This is not allowed in AngularJS. You can have multiple adjacent applications on a page, but then you have to bootstrap them explicitly. See this answer

1 Comment

The link is for adjacent applications and does not apply to nested apps, this can be misleading.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.