I have two ng-app in my application app1 and app2 and two firstcontroller and secondcontroller respectively.
The problem is that the second controller is executed first, and then the first controller.
But I want to execute sequentially as the 1st controller, then the 2nd controller.
please provide a solution for this.
thanks in advance.
var app1 = angular.module('firstapp', []); app1.controller("firstcontroller",function($scope){ $scope.arr1={name:'arjun'}; alert($scope.arr1.name); }); var app2 = angular.module('secondapp', []); app2.controller("secondcontroller",function($scope){ console.log("come to second app"); $scope.arr2={title:'kumar'}; alert($scope.arr2.title); }); angular.bootstrap(document.getElementById("app2"),['secondapp']);
<body > <div id="app1" data-ng-app="firstapp" data-ng-controller="firstcontroller"> <p>{{arr1.name}}</p> </div> <div id="app2" data-ng-app="secondapp" data-ng-controller="secondcontroller"> <p>{{arr2.title}}</p> </div> </body>
source share