0

Only the first ng-app works: see my plunker

How can I make both app work together? I understand that I should a line to bootstrap the modules, i'm not sure where exactly to add that line.

HTML

<head>
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.js"></script>
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular-animate.js"></script>
  <script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.13.4.js"></script>
  <script src="clientsearch.js"></script>
  <script src="datepicker.js"></script>
  <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
</head>

<body>
    <div class="container">


    <div ng-app="ui.bootstrap.demo">
    <div ng-controller="DatepickerDemoCtrl">
        <div class="row">
           <div class="col-md-6">
                <label for="appointment_start">Appointment start:</label>
                <p class="input-group">
                  <input type="text" id="appointment_start" name="appointment_start" class="form-control" readonly datepicker-popup="{{format}}" ng-model="dt1" is-open="opened1" max-date="'2020-06-22'" datepicker-options="dateOptions" date-disabled="disabled(date, mode)" ng-required="true" close-text="Close" />
                  <span class="input-group-btn">
                    <button type="button" class="btn btn-default" ng-click="open($event,'opened1')"><i class="glyphicon glyphicon-calendar"></i></button>
                  </span>
                </p>

           </div>
      </div>
    </div> <!-- ng-controller -->
    </div> <!-- ng-app -->



    <div id="appclientcomplete" ng-app="ui.bootstrap.clientautocomplete">
    <div ng-controller="TypeaheadCtrl">
     <div class="row">
        <h4>Static arrays</h4>
        <pre>Model: {{selected | json}}</pre>
        <input type="text" placeholder="Type client's name, address or phone number" ng-model="selected" typeahead="client as client.first_name + ' ' + client.last_name + ' ' + client.address_1 + ' ' + client.address_2 + ' ' + client.city  for client in clients | filter:$viewValue | limitTo:8" class="form-control">
      </div>
    </div> <!-- ng-controller -->
    </div> <!-- ng-app -->


    </div>  
</body>

datepicker.js

angular
  .module('ui.bootstrap.demo', ['ngAnimate', 'ui.bootstrap'])
  .controller('DatepickerDemoCtrl', function ($scope) {


}); 

clientsearch.js

angular.module('ui.bootstrap.clientautocomplete', ['ngAnimate', 'ui.bootstrap']);
angular.module('ui.bootstrap.clientautocomplete').controller('TypeaheadCtrl', function($scope, $http) {


});

1 Answer 1

1

If I'm not mistaken, Angular will only bootstrap the first ng-app it encounters. You should only use one app (module) but you can easily create a module that uses the other two modules.

angular.module("app", ["ui.bootstrap.demo", "ui.bootstrap.clientautocomplete"]);

ng-app="app"
Sign up to request clarification or add additional context in comments.

1 Comment

It worked, added <script>angular.module("app", ["ui.bootstrap.demo", "ui.bootstrap.clientautocomplete"]);</script> to HEAD and ng-app="app" to BODY. Thanks!

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.